Are [^\s] and \S equivalent in canonic (widely accepted standards of) regular expressions? If not what is the difference?

(Both seem to match any non-whitespace character.)

Reason I ask: see [^\s] widely used even by seasoned regex writers and wonder why is that given \S is shorter and easier to read - for me at least.

1 Answer 1


Both mean strictly the same: 1 non space character.

I don't know the reason why people doesn't use it, may be they are not aware of.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .