I have the following as3 function below which converts normal html with links so that the links have 'event:' prepended so that I can catch them with a TextEvent listener.
protected function convertLinks(str:String):String
{
var p1:RegExp = /href|HREF="(.[^"]*)"/gs;
str = str.replace(p1,'HREF="event:$1"');
return str;
}
For example
<a href="http://www.somedomain.com">
gets converted to
<a href="event:http://www.somedomain.com">
This works just fine, but i have a problem with links that have already been converted.
I need to exclude the situation where i have a string such as
<a href="event:http://www.somedomain.com">
put through the function, because at the moment this gets converted to
<a href="event:event:http://www.somedomain.com">
Which breaks the link.
How can i modify my function so that links with 'event:' at the start are NOT matched and are left unchanged?