P is for Practical | |
PerlMonks |
Re: regex: how to negate a set of character ranges?by Sidhekin (Priest) |
on Apr 29, 2007 at 17:59 UTC ( [id://612658]=note: print w/replies, xml ) | Need Help?? |
<clippy>It looks like you are trying to build a negated character class. Would you like some help?</clippy> You have the syntax for including several ranges within a character class wrong. Simple rule: Within a character class, [, |, and whitespace (even with /x) are literal, and ] terminates the class (except in first position). So keep those square braces out until constructing the class, and keep the pipes and whitespace out, period. Ah, but then, clippy may have been wrong? What you are trying to do is combine (and then negate) multi-character sequences, right? Oh my. Combining is easy. What you have even works, though I'd personally use qr//x instead:
Negating is another subject alltogether, since there is more than one set of semantics for such a negation. I'm not entirely sure which makes more sense here ... if any! Here's one example/guess though:
But do you have to read STDIN as bytes? If you could read it as characters (in whatever encoding this is; see Encode), you'd be spared this mess.
print "Just another Perl ${\(trickster and hacker)},"
In Section
Seekers of Perl Wisdom
|
|