Negating specific characters in regex

Use \S (which is negation of \s = non-whitespace character):

@"^\S+$"

If empty string is allowed, replace + with *:

@"^\S*$"

Leave a Comment