These aren't the characters you're looking for...

David Cantrell david at cantrell.org.uk
Tue Aug 19 14:17:39 BST 2008


On Tue, Aug 19, 2008 at 10:46:45AM +0100, Andy Wardley wrote:
> I mistakenly wrote this the other day:
> 
>     [\s^\n]
> 
> What I wanted was to match a whitespace character that wasn't a newline.
> 
> Of course, it doesn't work.  The '^' must be at the start for it to work as 
> a character class negatorificator.  And you can't mix "inny" classes with 
> "outy" classes.  That's just not allowed.
> 
> Of course, I could just write this:
> 
>     [ \t]
> 
> But that doesn't include the Unicode whitespace characters which \s would
> normally match.  So I ended up writing this:
> 
>     [ \t\x{85}\x{2028}\x{2029}]

Does that match all of newline, carriage return, formfeed and vertical
tab?

Can you instead look for [^\S\n]?

-- 
David Cantrell | Minister for Arbitrary Justice

What is the difference between hearing aliens through the
fillings in your teeth and hearing Jesus in your heart?


More information about the london.pm mailing list