You could always use one of the character classes. I would say use
[:blank:] when the usage context is textual, and use
[:space:] when it is programmatic, i.e. plain text vs source code.
When entered interactively, this seems to work:
=[[:blank:]^J]*. You can enter
^J by just quoting your newline: C-q C-j. In elisp the usual
I tested interactive use with
isearch-forward-regexp, and elisp use with M-:
Edit: (to clarify comments)
If you compare the docs for
\s with that for
[[:blank:]]* (linked above), the latter is a superset. If your use case considers characters like tab as whitespace, you should use the latter, if not,
\s should be fine.
A couple of examples:
- Say you are looking for a name (variable, function, etc) in C++ source,
\s would be sufficient.
- You want to change the indentation in a plain text notes file,
[:blank:] would be better suited.
Although, this may not be a hard and fast rule, as many source files can contain tabs as whitespace. That's exactly why this is for you to judge case by case.