The warning is telling you that the block ()*
is greedy, meaning that it will try to match maximum occurrences of statement
or functionDec1
which, depending on the situation, might not be what you expect.
Changing it to ()*?
makes it non-greedy, as suggested by the warning. This means it will match minimum occurrences of statement
or functionDec1
.
Expression examples with strings:
Samples:
foofoobar
foobarbar
foofoobarbarbar
Expression:
(foo|bar)*bar
Will give result:
foofoobar
foobarbar
foofoobarbarbar
Expression:
(foo|bar)*?bar
Will give result:
foofoobar
foobar
foofoobar
For the last one, the result will stop at the first bar