How do I use substrings in regular expressions?

Terry Vogelaar tvogelaar at de-mare.nl
Tue Apr 13 14:55:37 EDT 2010


I cannot get this regex to work:

put replacetext(textBlock,q("<IMG SRC='([^']*)' ([^>]*) ID='" & idNumber & "' ([^>]*)>"), q("<IMG SRC='" & newPath & "' \2 \3>")) into textBlock

The purpose is to replace:
<IMG SRC="flashblocks/editors/Mediablock.swf" WIDTH="300" HEIGHT="100" ID="ID3" ALIGN="left" VSPACE="2" HSPACE="8">
with:
<IMG SRC="flashblocks/data/resize/home1_holder_txt_ID3_mb.jpg" WIDTH="300" HEIGHT="100" ALIGN="left" VSPACE="2" HSPACE="8">

The \2 and \3 part should insert the substrings matching ([^>]*). This is working in BBEdit, but Rev gave me literally "\2 \3>": 
<IMG SRC="flashblocks/data/resize/home1_holder_txt_ID3_mb.jpg" \2 \3>

I cannot use the normal replace command, because it should only work when the ID attribute is matched. 

Terry


More information about the use-livecode mailing list