Jack Gates wrote:
On Friday 26 September 2008 12:48:14 pm Jack Gates wrote:
s!(<|</)([^\!][A-Z0-9 ]+>)!$1\L$2\E!g;
or
s/(<|<\/)([^!][A-Z0-9 ]+>)/$1\L$2\E/g;
The RE above captures and replaces all HTML tags with lowercase
as desired except for any tag that has only one letter such as
<P>, <B> or <I>
It will get the </B>, </P> and </I>
It properly ignores the <!DOCTYPE> tag
What is the correct way to write the above RE?
John helped me achieve what I wanted. His RE sample got me to the
right place after tweaking it a little.
I would like to understand why what I originally had did not work,
so I can learn better. Will some one show me why my original RE did
not work? Meaning it did not get the tags as explained above
previously.
Match '<' or '</' followed by one character that is not '!' followed by
one or more of 'A-Z0-9 ' followed by '>'.
Your pattern will not match '<I>' because that contains three characters
but your pattern has to match at least four characters.
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/