Sample Data:
<P>Active Component Answer
<P>
<P>One Answer with 3 bullets.</P>
<UL><LI dir=ltr>Bullet 1 - Text
<UL>
<LI dir=ltr>Bullet 2 - Text
<UL>
<LI dir=ltr>Bullet 3 - Text</LI></UL></LI></UL></LI></UL>
<P>No Bullet Text to end this Answer</P>
I've been using: (formatted in javascript)
$someString =~ s/<.*?>//gis ;
$someString =~ s/<[^>]*>//gis ;
However, now I need to SAVE some data to use in a substitution and remove the rest. Please post any RegExp you know of that would end with the final output below.
RegExp Sample Data:
<P>Active Component Answer
<P>
<P>One Answer with 3 bullets.</P>
<UL><LI>Bullet 1 - Text
<UL>
<LI>Bullet 2 - Text
<UL>
<LI>Bullet 3 - Text</LI></UL></LI></UL></LI></UL>
<P>No Bullet Text to end this Answer</P>
P.S
Primarily what I plan to do is read each 'tag' <sometext> and if it has space store all text after the < but before the space, and remove anything from the space to the >:
<LI dir=ltr> -> $1 = LI -> <LI>
BUT, using the same RegExp to do the above, if the tag is already properly formatted without a space output it how it is:
<UL> -> $1 = UL -> <UL>
</UL> -> $1 = /UL -> </UL>
Thanks for any aid, I'm slowly learning RegExp but man are they confusing sometimes.
6hrs and still going... think its lunch time before I die.
final expression that did the trick was
string.replace(/(<[^ >\s:]+)[^>]*>/gim,"$1>")
so guessing in perl it would be
s/(<[^ >\s:]+)[^>]*>/$1>/gim ;
Ended up using killroy's initial logic but had to add the \s.* so the stored val would not include the whitespace or any text following it.
Thanks again, I will get these RegExp down yet especially with this editor I've been working on.