I have the following as3 function below that converts normal html with links so that the links have an event: event so that I can catch them using 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 instance
<a href="http://www.somedomain.com">
converted to
<a href="event:http://www.somedomain.com">
This works fine, but I have a problem with links that have already been converted.
I need to rule out a situation where I have a string such as
<a href="event:http://www.somedomain.com">
through a function, because at the moment it is converted to
<a href="event:event:http://www.somedomain.com">
What breaks the connection.
How can I change my function so that the links with "event:" at the beginning do NOT match and remain unchanged?
Stanz source
share