regex start-of-line
spir
denis.spir at gmail.com
Sat Feb 12 09:19:49 PST 2011
Hello,
I have a regex bug in following conditions: users pass a series of regex
formats (strings) from which I create regex engines later used for lexing. To
ensure matching at start of (rest of) source, I prefix each format with '^'.
Right in most cases. But the following regex:
`^(true)|(false)`
matches "false" anywhere in text ==> bug. Is this normal? There is a kind of
ambiguity here, isn't there?
As a workaround, I replaced:
this.engine = Regex("^" ~ form);
by
this.engine = Regex(format("^(%s)", form));
And indeed
`^((true)|(false))`
does not match "false" anywhere else as at start of source.
Comments?
Denis
--
_________________
vita es estrany
spir.wikidot.com
More information about the Digitalmars-d-learn
mailing list