Emacs 26.1 In regexp help https://www.emacswiki.org/emacs/RegularExpression
has the next regexp:
[:space:] a whitespace character
Is this a same as:
and same as
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
I recommend reading the Emacs Lisp manual instead of Emacswiki.
Here's some of it on backslash sequences in regular expressions:
‘\sCODE’ matches any character whose syntax is CODE. Here CODE is a character that represents a syntax code: thus, ‘w’ for word constituent, ‘-’ for whitespace, ‘(’ for open parenthesis, etc. To represent whitespace syntax, use either ‘-’ or a space character. *Note Syntax Class Table::, for a list of syntax codes and the characters that stand for them.
The corresponding part on character classes:
‘[:space:]’ This matches any character that has whitespace syntax (*note Syntax Class Table::).
So, yes, they are the same, both are about characters with whitespace syntax. The exact meaning of whitespace syntax depends on the currently active syntax table, it can be customized by major modes and less commonly, by users. For example if someone defined the comma character to have whitespace syntax in Clojure buffers, then both
[[:space:]] would be matched by a comma.
To summarize, if you want to write a regex matching specific whitespace characters, then there's no other way to get there than actually spelling them out. In case you find it tedious to do so with strings, I highly recommend the built-in
rx library as alternative notation that's easier to generate and compose.