AW: How trim: Bug in RegExp engine
Dave Cragg
dcragg at lacscentre.co.uk
Sun Oct 23 06:23:16 EDT 2005
On 23 Oct 2005, at 11:03, Thomas Fischer wrote:
> Hi,
>
> 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.
>
> Try
> answer replaceText("A C","^ *","")
> I get "C", which obviously is not correct.
> If I remove the "*", I get "A C"
This may be a bug. (I'm not sure.)
But the following will work:
answer replaceText("A C","^ +","")
I.e. match "at least one" occurrence of a space, which is what is
intended.
Cheers
Dave
More information about the use-livecode
mailing list