0

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.

Ghost9
  • 249
  • 3
  • 7
  • 15

1 Answers1

1

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

annonymously
  • 4,708
  • 6
  • 33
  • 47
  • I'd like to use string replace, but the values between the identifiers will not be the same. I could possibly use index of and run a loop somehow. Reg expressions seem like they should make sense, but I haven't been able to get a custom one to work, so I think that'll require a lot more study if I'm going to do it that way. Every time I try a regex it's not finding the proper term. I don't think I understand the key to it. – Ghost9 Dec 19 '11 at 03:00
  • Regex is hard to understand at the beginning, but if you stick with it you can start to make sense of it. I'm no expert at it myself but I do know that if you get the indexes of '[caption]' and '[/caption]' and get the substrings around those indexes you can delete whats in between – annonymously Dec 19 '11 at 03:03
  • Awesome, I just tried that and got it to work! All I need to do now is put it in a loop until the index hits -1 so that it will remove all instances. Thanks man! (or woman) – Ghost9 Dec 19 '11 at 03:10
  • except, doh.. turns out i can't delete everything in between those brackets. I need to preserve the call to the image. now I need to figure out how to separate that out. – Ghost9 Dec 19 '11 at 03:13