Is there a way to convert the string
#ff00fffirstword#445533secondword#008877thirdword
into
<font color='#ff00ff'>firstword</font><font color='#445533'>secondword</font><font color='#008877'>thirdword</font>
Using regular expressions in either JavaScript or ActionScript 3?
I attempted the following code, but it's not flawless (ActionScript 3 code):
var pat:RegExp = /(#\w{6})([^#]+)/g;
var html:String = t.replace(pat, "<font color=\'$1\'>$2</font>");
trace(html); // output : <font color='#ff00ff'>firstword</font><font color='#445533'>secondword</font><font color='#008877'>thirdword</font>
If there is an additional #
in the string, the desired output may not be achieved. I am unsure of how to create a more robust regular expression for this task.