All whitespace characters except \n...

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

All whitespace characters except \n...

Post by Ollie Saunders »

How do I say match all whitespace characters except for \n.
I tried it with words - trying to match all word characters apart from "o":

[\w^o] : matched o anyway
[\w[^o]] : invalid
User avatar
GeertDD
Forum Contributor
Posts: 274
Joined: Sun Oct 22, 2006 1:47 am
Location: Belgium

Re: All whitespace characters except \n...

Post by GeertDD »

Code: Select all

(?:\s(?<!\n))+
It looks ugly because it is ugly.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Re: All whitespace characters except \n...

Post by Ollie Saunders »

Yes it does.
Post Reply