Regular expressions

Thierry Douez th.douez at gmail.com
Wed Oct 9 12:29:41 CEST 2013


Hi Terry,

I guess you may like to participate  in this thread:

   http://forums.runrev.com/viewtopic.php?f=66&t=17412

Regards,

Thierry

-----------------------------------------------------------------
2013/7/2 Terry Vogelaar <tvogelaar at de-mare.nl>
stringToChange: <body><span>Block of text</span></body>
matchExpression: <span>[^<]+</span>
replacementString: <div>?</div>
result: <body><div><span>Block of text</span></div></body>

The question-mark fills in everything that matches the matchExpression.
Very useful when you want to put something around the found instances.

Or you can even take it a step further by using ( and ) in combination with
\1, \2 etc.:

stringToChange: <body><span class="MakeMeVisible">Block of
text</span></body>
matchExpression: <span class="([^"]+)">([^<]+)</span>
replacementString: <span>\1: \2</span>
result: <body><span>MakeMeVisible: Block of text</span></body>

The \1 fills in what it found inside the first pair of parentheses; the \2
the second pair. This way you can do really powerful replacements, if you
know what you are doing.


------------------------------------------------
Thierry Douez - http://sunny-tdz.com
Maker of sunnYperl - sunnYmidi - sunnYmage


More information about the use-livecode mailing list