AW: How trim: Bug in RegExp engine
fischer at mail.sub.uni-goettingen.de
Sun Oct 23 05:03:47 CDT 2005
Wouter is right:
> It is indeed elegant, but a condition check is necessary here as it
> will remove the first word + the space(s) if there is no space at the
> start of the line.
> > " The cat sat on the mat. "
> But if no space in front the result is
> "cat sat on the mat. "
This is actually true -- and a serious bug in Revolution's RegExp engine.
The Regular Expression Syntax reference states:
^ matches the following character at the beginning of the string
^A matches "ABC" but not "CAB"
* matches zero or more occurrences of the preceding character or pattern
I assumed that Revolution would do what it promised and didn't check this.
answer replaceText("A C","^ *","")
I get "C", which obviously is not correct.
If I remove the "*", I get "A C"
gives "C", so "^A*" matches "BA".
This must not happen.
It looks like "^A*" is incorrectly interpreted as "^.*A*".
Parentheses don't help, but might make things worse:
gives an empty result. No idea why.
All the best
More information about the use-livecode