regex to match any space but not new line 07-11-2014d1135 [^\S\n] quote: That is, not-not-whitespace or not-newline. Distributing the outer not (i.e., the complementing ^ in the character class) with De Morgan's law, this is equivalent to “whitespace and not newline� -http://stackoverflow.com/questions/3469080/how-do-i-match-whitespace-but-not-newlines There is also [ \t]