[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/
- [Octave-bug-tracker] [bug #54592] regexprep gets confused when parentheses should be processed, Docf, 2018/08/29
- [Octave-bug-tracker] [bug #54592] regexprep gets confused when parentheses should be processed, Pantxo Diribarne, 2018/08/29
- [Octave-bug-tracker] [bug #54592] regexprep gets confused when parentheses should be processed, Docf, 2018/08/29
- [Octave-bug-tracker] [bug #54592] regexprep gets confused when parentheses should be processed, Pantxo Diribarne, 2018/08/30
- [Octave-bug-tracker] [bug #54592] regexprep gets confused when parentheses should be processed, Rik, 2018/08/30
- [Octave-bug-tracker] [bug #54592] regexprep gets confused when parentheses should be processed, Docf, 2018/08/31
- [Octave-bug-tracker] [bug #54592] regexprep gets confused when parentheses should be processed, Philip Nienhuis, 2018/08/31
- [Octave-bug-tracker] [bug #54592] regexprep gets confused when parentheses should be processed,
Mike Miller <=
- [Octave-bug-tracker] [bug #54592] regexprep gets confused when parentheses should be processed, Rik, 2018/08/31