Regular expression replace
plemay at readnaturally.com
Fri Sep 9 10:49:15 CDT 2005
I want to do several replaces using a regular expression in Revolution.
Here are two runable examples, but they both have problems.
In these examples, I want these replacements:
[rnNF2] replaced by [2F]
[rnNF3] replaced by [3F]
[rnNW3] replaced by [3W]
The first example uses replaceText and works as a 'replace all'. But the
3rd parameter is a literal. When I try this, the $1 and $2 do not
represent the (parenthesis-delimited) groups the way normal regex does.
The second example uses matchText and only replaces the first instance.
I could probably use this in a repeat, but there should be a better way.
put "the first test [rnNF2] the second test [rnNF3] and the third test
[rnNW3] are all here" into testIn
put replaceText(testIn, "\[rnN([FWS])([1-8])\]", "[$2$1]") into testOut
put matchText(testIn,"\[rnN([FWS])([1-8])\]", theSeason, theGrade) into
answer "gotPhone=" & gotPhone & ", theSeason=" & theSeason & ",
theGrade=" & theGrade
More information about the use-livecode