in reply to RegEx Against Arbitrary XML Tags
GrandFather's answer is certainly the right way to go, but while we're here, let's look at your regular expression:
if($line =~ /^\s*<(\w+)>[^\w*|\d*|<]/)Breaking it down:
- ^\s*
- Anchor the start, zero or more spaces
- <(\w+)>
- One or more word-characters in <> (so far so good)
- [^\w*|\d*|<]
- A single character ([..] is a character class) which is not (^) a word character, (\w), an asterisk (*), a pipe (|) or a less-than sign (<). Note that \d is included under \w.
I'm not quite sure what you wanted at the end there, but parens ((...|...)) are probably closer than a character class ([]).
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: RegEx Against Arbitrary XML Tags
by onegative (Scribe) on Oct 20, 2011 at 13:39 UTC | |
by Jenda (Abbot) on Oct 20, 2011 at 14:11 UTC | |
by Anonymous Monk on Oct 20, 2011 at 14:23 UTC |
In Section
Seekers of Perl Wisdom