comparison 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
comparison
equal deleted inserted replaced
31120:d8d90ba892b0 31121:7d3bda173b63
1198 %! assert (regexp ('foo!+bar', '\<\w'), [1, 6]); 1198 %! assert (regexp ('foo!+bar', '\<\w'), [1, 6]);
1199 %! assert (regexp ('foo!+bar', '.\>'), [3, 4, 8]); 1199 %! assert (regexp ('foo!+bar', '.\>'), [3, 4, 8]);
1200 %! assert (regexp ('foo!+bar\nbar!+foo', '.\>'), [3, 4, 8, 13, 14, 18]); 1200 %! assert (regexp ('foo!+bar\nbar!+foo', '.\>'), [3, 4, 8, 13, 14, 18]);
1201 %! assert (regexp ('foo!+bar\nbar!+foo', '\<\w'), [1, 6, 10, 16]); 1201 %! assert (regexp ('foo!+bar\nbar!+foo', '\<\w'), [1, 6, 10, 16]);
1202 1202
1203 ## Test "incomplete" named patterns
1204 %!assert <*62705> (regexpi ('<', '\(?<'), 1)
1205 %!assert <*62705> (regexpi ('<n>', '\(?<n\>'), 1)
1206 %!assert <*62705> (regexpi ('<n>', '\(?<n\>\)?'), 1)
1207 %!assert <62705> (regexpi ('<n>a', '\(?<n\>a\)?'), 1)
1208
1203 ## Test input validation 1209 ## Test input validation
1204 %!error regexp ('string', 'tri', 'BadArg') 1210 %!error regexp ('string', 'tri', 'BadArg')
1205 %!error regexp ('string') 1211 %!error regexp ('string')
1206 1212
1207 */ 1213 */