AW: How trim: Bug in RegExp engine
Ken Ray
kray at sonsothunder.com
Mon Oct 24 21:17:17 EDT 2005
On 10/24/05 4:51 PM, "Marielle Lange" <mlange at lexicall.org> wrote:
> Yuk!!!
>
> If the programmers have to check up regular expressions anyway, can I
> suggest they make the matchtext consider the full text and not just
> match ***within*** a line of text. Okay for "^" and "$" to correspond
> to the start and end of a line of text, this is what happens in all
> programs that allow for regular expression.
>
> But in all programs that implement regular expressions, the following
> happens:
> put replaceText("DA" & cr & "CD","A.?C","") -> DD
> put replaceText("DA" & tab & "CD","A.?C","") -> DD
>
> In revolution, this happens:
> put replaceText("DA" & cr & "CD","A.?C","") -> DA cr CD
> put replaceText("DA" & tab & "CD","A.?C","") -> DD
This is because the PCRE engine needs to be explicitly told that you want to
treat multiple lines as a single "block", otherwise it looks for a match on
each line. To do this, you need to preface the expression with "(?s)", as
in:
put replaceText("DA" & cr & "CD","(?s)A.?C","")
and you get back "DD" as you'd expect. (For more info, see the docs at
http://www.pcre.org/man.txt.)
Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com
More information about the use-livecode
mailing list