octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #54592] regexprep gets confused when parenthes


From: Mike Miller
Subject: [Octave-bug-tracker] [bug #54592] regexprep gets confused when parentheses should be processed
Date: Fri, 31 Aug 2018 13:07:21 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0

Follow-up Comment #7, bug #54592 (project octave):

Can someone test the same, with an unmatched opening bracket? For example


regexprep ('tes(t', '(', '')
regexprep ('tes[t', '[', '')


It looks to me like both Perl and sed treat an unmatched ']' the same as '\]',
but an unmatched '[' is an error. This is specifically documented in the Perl
RE syntax as an exception. The ']' character is called a "sometimes
metacharacter", but the '()' characters are always metacharacters.

However, POSIX extended regular expression syntax seems to allow a ')' to be
interpreted as a normal character when there is no corresponding '('. So under
POSIX ERE rules, ')' is also a "sometimes metacharacter", but not under Perl
RE rules.

This can be confimed with grep


$ echo 'tes)t' | grep -E ')'
tes)t
$ echo 'tes)t' | grep -P ')'
grep: unmatched parentheses


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?54592>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]