replaceText
Posted: Wed Apr 12, 2006 4:05 am
The replaceText function does not seem to embody (or perhaps no documentation exists to support) all regular expression statements as the perl ~s or the python re.sub, even though the docs state "Searches for a regular expression and replaces the portions that match the regular expression". More specifically, I could not find a way to use regular expression groups (not even in Dan Shafer's book). In pcre, perl, python, etc. the way to describe a group is either with $groupnumber or \groupnumber, but in runtime revolution neither way seems to work. To illustrate with a simple example (I am aware that the following can be performed using chunks, but more complicated expressions cannot):
Let us assume that var1 equals "Hello again world!"
In perl you can do:
$var1=~s/(Hello)(.*)(world!)/$1 $3/; #Group 1 equals Hello, group 3 world. The second group is discarded.
In python you can do:
var1=re.sub(r'(Hello)(.*)(world!)',r'\1'+' '+r'\3',var1) #Group 1 equals Hello, group 3 world. The second group is discarded.
In both situations, the resulting var1 would be "Hello world!".
So, to cut a long story short, is there a possibility of full regular expressions support (either through replaceText, or even through a new future function)?
Let us assume that var1 equals "Hello again world!"
In perl you can do:
$var1=~s/(Hello)(.*)(world!)/$1 $3/; #Group 1 equals Hello, group 3 world. The second group is discarded.
In python you can do:
var1=re.sub(r'(Hello)(.*)(world!)',r'\1'+' '+r'\3',var1) #Group 1 equals Hello, group 3 world. The second group is discarded.
In both situations, the resulting var1 would be "Hello world!".
So, to cut a long story short, is there a possibility of full regular expressions support (either through replaceText, or even through a new future function)?