Page 1 of 1

Help with Surrounding Links

Posted: Sun Jan 11, 2009 8:05 pm
by Jam
Hi,

I have files that look something like this :

Code: Select all

<a href="http://www.example.com">example</a>

<a href="http://www.example.com">example</a>
And they need to be changed to this :

Code: Select all

$advarray[] = '<a href="http://www.example.com">example</a>';

$advarray[] = '<a href="http://www.example.com">example</a>';
So it's just a matter of appending and prepending everything between <a and /a>

In all cases there is only one link on each line, in case that matters.

I've tried following lots of examples from the documentation and the forum, but I must be missing something because every time I use \1 or $0 or $1 in the replace text, it results in actually printing \1 or $0 or $1 instead of the original text...

Thanks,
Jam

Posted: Sun Jan 11, 2009 8:22 pm
by ben_josephs
Select Replacement format:
Find what: <a .*?</a>
Replace with: $advarray[] = '$0';

[X] Regular expression
[X] Replacement format

Posted: Sun Jan 11, 2009 8:28 pm
by Jam
Wow, that was an amazingly quick reply, and it works perfectly.

ben_josephs, you are much appreciated.

Thanks!