Can I convert the string #ff00fffirstword#445533secondword#008877thirdword to
<font color='#ff00ff'>firstword</font><font color='#445533'>secondword</font><font color='#008877'>thirdword</font>
Using regexp in javascript or actioncript3 program?
I tried the code below, but it is not perfect (actionscript3 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 another # in this line, the result will not be what I want. I do not know how to write a strong regexp to achieve this.
source share