Link to home
Start Free TrialLog in
Avatar of Igiwwa
Igiwwa

asked on

Reg Ex Alter and Replace

Hello All.

I need to change:

<previous art_id="[something]">[something2]</previous>
to
<a href="[something2]">[something2]</a>

However, the first for the first [something2] I need to replace special characters like whitespaces before i rewrite it.  So this wouldn't work:

$content=~s /<previous art_id=\"[a-zA-Z0-9._-]+\">(.*)<\/previous>/<a href=\"$1\">$1<\/a>/gi;

Because the first $1 still has characters that I want to replace for links.

For an actual example:

<previous art_id="insurance">Homeowner's Insurance</previous>
needs to be
<a href="Homeowner&#39;s+Insurance">Homeowner's Insurance</a>

Thanks for the help in advance!  Hope I made everything clear enough.
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Igiwwa
Igiwwa

ASKER

awesome, thank you.