panzhuli
panzhuli

Reputation: 2940

Regular Expression help in AS3

I have to use tinymce as a wysiwyg editor in a CMS to populate a flash app. I need to strip out the modern HTML in favor of something flash can use. Here's what I'm trying:

var initUnderline:RegExp = new RegExp('<span style="text-decoration: underline;">', "gi");
var endUnderline:RegExp = new RegExp("</span>", "gi");
var string:String = $.xmlData.content.landing.overview;//load the content from xml
var safeStr:String = string.replace(initUnderline, '<span style="text-decoration: underline;"><u>');
safeStr = string.replace(endUnderline, '</u></span>');

however, this only works for the endUnderline RegExp. The initial is not being replaced. Ideas?

I'm not great with regExps at all!

Upvotes: 0

Views: 161

Answers (1)

Claus Wahlers
Claus Wahlers

Reputation: 1231

There's nothing wrong with your regexp stuff per se.

The bug is that you need to run the second replace on safeStr, not on string:

var safeStr:String = string.replace(initUnderline, '<u>');
safeStr = safeStr.replace(endUnderline, '</u>');

Upvotes: 1

Related Questions