首先,为我的菜鸟行为感到抱歉。相信我,我说我一直在做 rtfm。我不是懒惰,我只是愚蠢(显然)。从好的方面来说,这可以让某人轻松获得一些积分。
我尝试使用包含特殊字符的模式进行匹配/替换,但在 Flex 3 应用程序中遇到语法错误。我只想编译以下正则表达式...(同时也用“”替换html标签)
value.replace(/</?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)/?>/g, "");
顺便说一句,模式 /<.*?>/g 在以下情况下不起作用是标签之间的 html 实体,
像这样:
<TEXTFORMAT LEADING="2">
<P ALIGN="LEFT">
<FONT FACE="Arial" SIZE="11" COLOR="#4F4A4A" LETTERSPACING="0" KERNING="0"><one</FONT>
</P>
</TEXTFORMAT><TEXTFORMAT LEADING="2">
<P ALIGN="LEFT">
<FONT FACE="Arial" SIZE="11" COLOR="#4F4A4A" LETTERSPACING="0" KERNING="0">two</FONT>
</P>
</TEXTFORMAT>
第一个正则表达式将同时得到 " 但第二个正则表达式只会得到 "hi"
谢谢!
刺刀L
First off, sorry for my noob-ness. Believe me when i say ive been rtfm'ing. Im not lazy, im just dumb (apparently). On the bright side, this could earn someone some easy points here.
I'm trying to do a match/replace with a pattern that contains special characters, and running into syntax errors in a Flex 3 app. I just want the following regex to compile... (while also replacing html tags with "")
value.replace(/</?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)/?>/g, "");
On a side note, the pattern /<.*?>/g wouldn't work in cases where there are html entities between tags,
like so:
<TEXTFORMAT LEADING="2">
<P ALIGN="LEFT">
<FONT FACE="Arial" SIZE="11" COLOR="#4F4A4A" LETTERSPACING="0" KERNING="0"><one</FONT>
</P>
</TEXTFORMAT><TEXTFORMAT LEADING="2">
<P ALIGN="LEFT">
<FONT FACE="Arial" SIZE="11" COLOR="#4F4A4A" LETTERSPACING="0" KERNING="0">two</FONT>
</P>
</TEXTFORMAT>
The first regex would get both "<one" and "two",
but the second would only get "hi"
Thanks!
Stabby L
发布评论
评论(1)
这是您要查找的内容:
请参阅 http: //fightskillz.com/2010/01/flexactionscript-3-0-strip-html-tags-function/ 了解更多信息。
Here is what you are looking for:
see http://fightskillz.com/2010/01/flexactionscript-3-0-strip-html-tags-function/ for more information.