I'm using regular expressions to match any number of white space characters. Is there a difference between the following?
" *"
"\s*"
Are there special cases where either would cause an issue?
I'm using regular expressions to match any number of white space characters. Is there a difference between the following?
" *"
"\s*"
Are there special cases where either would cause an issue?
" *"
will only match zero or more of the [SPACE] character and only the [SPACE] character.
"\s*"
will match zero or more of ANY whitespace character ( SPACE, TAB, FORMFEED, etc. ).
Therefore they are not equivalent expressions. \s
is what you want usually, especially since you can't readily see whitespace characters by definition.
This is the difference between the regular space () and any space (space, tab, line breaks, etc.).
See reference here.