backreferences in PCRE?

Alex Rice alex at mindlube.com
Thu Nov 13 14:40:29 EST 2003


I can't remember- are any of Rev's REGEX functions capable of doing 
backreferences?

Consider this perl script. It will put a "\" before any quote 
character, but only if it's not already preceded by a "\" character.

$txt = "fu\"bar askldj askld\\\"asd lakj sdkljasd\"";
print "before: ", $txt, "\n";
if($txt =~ s/([^\\])"/$1\\"/g) {
     print "result: ", $txt,"\n";
}

# ./test.pl
before: fu"bar askldj askld\"asd lakj sdkljasd"
result: fu\"bar askldj askld\"asd lakj sdkljasd\"

In transcript I thought it should be :

replaceText(pStr, "([^\\])"&quote, "$1\"&quote)

Which works *except* for the $1 is used literally instead of as a 
backreference.

Alex Rice <alex at mindlube.com> | Mindlube Software | 
<http://mindlube.com>

what a waste of thumbs that are opposable
to make machines that are disposable  -Ani DiFranco



More information about the use-livecode mailing list