Simple syntax question

Posted by stabby on Stack Overflow See other posts from Stack Overflow or by stabby
Published on 2010-02-17T19:19:04Z Indexed on 2010/03/27 22:03 UTC
Read the original article Hit count: 118

Hey everyone,

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

© Stack Overflow or respective owner

Related posts about flex3

Related posts about actionscript-3