Could anyone help me to assemble a pattern that matches an arbitrary sequence of spaces and tabs?
[ \t]+
will match arbitrary sequences (e.g., spaces followed by tabs followed by more spaces ...).
( |\t)+
will match a sequence of one or more spaces or tabs, is that what you're looking for ?
To piggy-back on @Justin Morgan's answer, note that according to https://regex101.com/, \s+
is equal to [\r\n\t\f\v ]+
.
Therefore, if your system doesn't support the \s+
(or \s*
) construct, use [\r\n\t\f\v ]
in place of the \s
part instead.
\s+
should capture all whitespace, including spaces, tabs, carriage returns, and some weird whitespace characters. Use \s*
if you want it to be optional.