I've been playing around with rx lately, and I just noticed there are (at least) 3 different ways of indicating whitespaces in regular expressions.

  1. [:blank:]
  2. [:space:]
  3. \s-

What are the differences between each of them? Does it depend on the major-mode?


The [:blank:] character class matches only the SPC and TAB characters. The other two match whitespace based on the active syntax table.

There does not seem to be a difference between [:space:] and \s-. The latter is an instance of the general \scode pattern for matching based on a syntax class.

  • 1
    Just did a quick test modifying the syntax table in a buffer to make additional characters whitespace. Testing with regexp-builder I can confirm that both [:space:] and \s- match the additional characters as spaces. – glucas Nov 15 '14 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.