嗨,我有一些来自富文本控件的html文本。类似于:
<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Verdana" SIZE="10" COLOR="#0000FF" LETTERSPACING="0" KERNING="0"><A HREF="event:http://bbc.co.uk" TARGET="_blank"><U>l</U></A><U>ink1</U><FONT COLOR="#000000"> blah blah blah. another <FONT COLOR="#0000FF"><A HREF="event:http://cnet.com" TARGET="_blank"><U>link2</U></A></FONT> blah blah</FONT></FONT></P></TEXTFORMAT>我想提取所有的A标签,即:
<A HREF="event:http://cnet.com" TARGET="_blank"><U>link2</U></A>我是否应该查看reg表达式,或者是否有任何字符串实用程序可以实现这一点。
任何提示/帮助都非常感谢。
发布于 2009-11-03 17:48:50
雅,你需要研究正则表达式,因为字符串实用程序是基本的字符串操作技术。您可以从以下内容开始:
var pattern:RegExp = /<A.*?</A>/;
var str:String = '<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Verdana" SIZE="10" COLOR="#0000FF" LETTERSPACING="0" KERNING="0"><A HREF="event:http://bbc.co.uk" TARGET="_blank"><U>l</U></A><U>ink1</U><FONT COLOR="#000000"> blah blah blah. another <FONT COLOR="#0000FF"><A HREF="event:http://cnet.com" TARGET="_blank"><U>link2</U></A></FONT> blah blah</FONT></FONT></P></TEXTFORMAT>';
trace(pattern.exec(str));
它将输出<A HREF="event:http://bbc.co.uk" TARGET="_blank"><U>l</U></A>.
https://stackoverflow.com/questions/1665940
复制相似问题