replace based on variable within string
Posted: Thu Nov 10, 2011 12:01 pm
With the text file I have a line like this
<IMG src="/pages/cat/jpgs/IRFMR_A.jpg">
And I need to change it to this
<a href="/pages/cat/jpgs/IRFMR_A .jpg" rel="prettyPhoto"><img src="/pages/cat/jpgs/IRFMR_A.jpg" align="middle" border="0" width="250"></a>
BUT the image filename, in this case IRFMR_A .jpg is different in each text file. So I need to extract the image filename and use it within the replace.
Is there any way to code this with regex??
I have thousands of these to do so any help much appreciated!
Thanks in advance
Alan
<IMG src="/pages/cat/jpgs/IRFMR_A.jpg">
And I need to change it to this
<a href="/pages/cat/jpgs/IRFMR_A .jpg" rel="prettyPhoto"><img src="/pages/cat/jpgs/IRFMR_A.jpg" align="middle" border="0" width="250"></a>
BUT the image filename, in this case IRFMR_A .jpg is different in each text file. So I need to extract the image filename and use it within the replace.
Is there any way to code this with regex??
I have thousands of these to do so any help much appreciated!
Thanks in advance
Alan