I am trying to match meta characters "tab" and "newline", but without "spaces" with REGEX in Java.
\ s matches evrything, i.e. tab, space and new line ... But I do not want the "space" to match.
How to do it?
Thanks.
One way to do this:
[^\\S ]
The character class being denied makes this regular expression match anything except - \\S (non-whitespace) and " " (space). Thus, it will match \\S , except for a space.
\\S
" "
We explicitly list them inside [...] (character set):
[...]
"[\\t\\n\\r\\f\\v]"