对于一个项目,我正在尝试将htmlText导入到flash中,然后删除flash不会处理的任何项目。例如,我要导入的html包含自定义“[caption] [/ caption]”代码。我基本上想要删除这些标识符和它们之间的任何文本,以便flash不会在文本字段中显示它们。有没有人对我有好的建议/例子?我一直在试图弄清楚如何使用正则表达式来做到这一点,但是找不到它的好指南却没有成功,所以失败了。
我试图过滤的文字示例:
<em>Pushmo</em> is a game filled with questions. How do I solve this puzzle? Is that a 8-bit Mario's face? Why is this old, obese blob making tons of death traps that easily ensnare and encase unsuspecting children?
[caption id="attachment_37414" align="alignleft" width="400" caption="The fat, red sumo goes into the most dangous place imaginable."]<a href="/2011/12/pushmo-review/pushmo-3ds-title-screen/" rel="attachment wp-att-37414"><img class="size-medium wp-image-37414" title="Pushmo-title" src="/2011/12/pushmo-3ds-title-screen-400x203.jpg" alt="Pushmo Title Screen" width="400" height="203" /></a>[/caption]
<em>Pushmo</em> is a downloadable puzzle game in the 3DS eShop. In <em>Pushmo</em> you take on the role of Mallo, an amorphic red sumo wrestler with the mind of an Einstienian savant.
我希望能够检测识别文本并删除它们之间的任何内容。我很感激任何人都可以给我的任何建议。
答案 0 :(得分:1)
您可以使用indexOf
和lastIndexOf
来实现此功能而无需正则表达式。
另外,您应该查看String.replace
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/String.html
和as3正则表达式教程:
http://snipplr.com/view/6608/as3-regular-expression-basics/
最后是纯正则表达式的教程: