Mercurial > jwe > octave
diff libinterp/corefcn/regexp.cc @ 31121:7d3bda173b63
regexp: Be more thorough in detecting named patterns.
* liboctave/util/lo-regexp.cc (regexp::compile_internal): Check more thoroughly
if named pattern expressions are complete before adapting syntax.
* libinterp/corefcn/regexp.cc (Fregexp): Add tests.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Mon, 04 Jul 2022 21:38:15 +0200 |
parents | d8d90ba892b0 |
children |
line wrap: on
line diff
--- a/libinterp/corefcn/regexp.cc Mon Jul 04 21:36:48 2022 +0200 +++ b/libinterp/corefcn/regexp.cc Mon Jul 04 21:38:15 2022 +0200 @@ -1200,6 +1200,12 @@ %! assert (regexp ('foo!+bar\nbar!+foo', '.\>'), [3, 4, 8, 13, 14, 18]); %! assert (regexp ('foo!+bar\nbar!+foo', '\<\w'), [1, 6, 10, 16]); +## Test "incomplete" named patterns +%!assert <*62705> (regexpi ('<', '\(?<'), 1) +%!assert <*62705> (regexpi ('<n>', '\(?<n\>'), 1) +%!assert <*62705> (regexpi ('<n>', '\(?<n\>\)?'), 1) +%!assert <62705> (regexpi ('<n>a', '\(?<n\>a\)?'), 1) + ## Test input validation %!error regexp ('string', 'tri', 'BadArg') %!error regexp ('string')