good chemistry is complicated,
and a little bit messy -LW
Regex: Char-class equivalent for [^]by LanX (Chancellor)
|on Jan 14, 2013 at 13:49 UTC||Need Help??|
LanX has asked for the
wisdom of the Perl Monks concerning the following question:
I read once that JS-regexes follow the standards of Perl4.
Now I was quite surprised to learn that JS doesn't have a /s single-line modifier to let '.' also match on linebreaks like \n.
As a compensation JS offers to use [^] to match everything (the negation of nothing is everything).
I like the concept and was wondering if there is any equivalent in Perl ...
Here [^] is a syntax error because at this position Perl magically expects ']' to be part of the negated char-class and still expects another closing ']'.
The closest that I was able to find was (?:.|\n)
Any other suggestions?
Another option is to use single-line locally: (see perlrecharclass)
not shorter but cleaner!