How to create a regex that will match an arbitrary sequence of spaces and tabs
Could anyone help me to assemble a pattern that matches an arbitrary sequence of spaces and tabs?
Solution 1:
[ \t]+
will match arbitrary sequences (e.g., spaces followed by tabs followed by more spaces ...).
Solution 2:
\s+
should capture all whitespace, including spaces, tabs, carriage returns, and some weird whitespace characters. Use \s*
if you want it to be optional.
Solution 3:
( |\t)+
will match a sequence of one or more spaces or tabs, is that what you're looking for ?