I tried this but it doesn't work :
[^\s-]
Any Ideas?
Non-whitespace character: \S.
The quantifier notations In regular expressions, the hyphen ("-") notation has special meaning; it indicates a range that would match any number from 0 to 9. As a result, you must escape the "-" character with a forward slash ("\") when matching the literal hyphens in a social security number.
A regex to match a string that does not contain only whitespace characters can be written in two ways. The first involves using wildcards (.) and the non-whitespace character set (\S), while the other one involves a positive lookahead to check that the string contains at least one non-whitespace character (\S).
A whitespace character is a space (U+0020), tab (U+0009), newline (U+000A), line tabulation (U+000B), form feed (U+000C), or carriage return (U+000D). A space is U+0020. A non-space character is any character that is not a whitespace character.
[^\s-]
should work and so will
[^-\s]
[]
: The char class^
: Inside the char class ^
is the negator when it appears in the beginning.\s
: short for a white space-
: a literal hyphen. A hyphen is a meta char inside a char class but not when it appears in the beginning or at the end.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With