|Just another Perl shrine|
RegEx: Why is [.] not a valid character class?by hoppfrosch (Scribe)
|on Nov 17, 2004 at 14:41 UTC||Need Help??|
hoppfrosch has asked for the
wisdom of the Perl Monks concerning the following question:
I've got a single string, containing the contents of a complete HTML-File (including CarriageReturns). This string contains several <table>...<\table> parts (with a lot of linebreaks in the ... part).
What I want to do is to get the first table from the string.
What I tried:
Further investigation shows, that [.] is not a valid character class ...
My questions are:
Why is '.' not allowed within a character class?
It's clear to me now that my desired character class [.\n] can be achieved with the s modifier - but why is there such an "inconsistent way" using a modifier to emulate a character class?
Why is there no "super" character class - matching ALL characters including '\n'?
What's the reason excluding '\n' from '.'? (Why is '\n' handled in a special way?)
Edit by castaway - use html entities instead of angled brackets