Ok am at my wits end with this one. No luck on google either and feels like am beating my head against a brick wall.
The problem: I have a string containing some HTML source. Within this source there is various links to different locations.
I need to get all the links and append a set of variables to them using a regular expression.
But i need to ensure that the URLs remain properly formed
Examples:
<a href="www.somesite.com">Some Site!</a>
Becomes - <a href="www.somesite.com?var1=foo&var2=bar">Some Site!</a>
<a href="http://www.somesite.com/mydir/index.php?somevar=value" title="A link" class="myLinks">Some Site!</a>
Becomes - <a href="http://www.somesite.com/mydir/index.php?var1=foo&var2=bar&somevar=value" title="A link" class="myLinks">Some Site!</a>
So basically I need to ensure that all other information remains untouched
any help to save me form going nuts would be appriciated
cheers
v_Ln