Question

For a project, I'm trying import htmlText into flash, and then remove any items flash will not process. For example, the html I want to import contains custom "[caption][/caption]" code. I essentially want to remove these identifiers and any text from in between them so that flash will not display them in a text field. Does anyone have a good suggestion/example for me? I have been trying to figure out how to use regular expressions to do this, but have been unsuccessful in finding a good guide for it and so have failed.

And example of text I'm trying to filter:

<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. 

I'm looking to be able to detect identifying text and remove anything between them. I'd appreciate any suggestions anyone can give me.

Était-ce utile?

La solution

You might be able to use indexOf and lastIndexOf to achieve this without regex.

Also you should have a look at String.replace

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/String.html

and an as3 regex tutorial:

http://snipplr.com/view/6608/as3-regular-expression-basics/

finally a tutorial for pure regex:

http://www.regular-expressions.info/tutorial.html

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top