Reference to 12.1 The Regular Expression for sentence-end of Elisp introduction

It illustrate alternatives of sentence-end as

 \\($\\| \\|  \\)
        ^   ^^
       TAB  SPC

and explains:

Two backslashes, ‘\\’, are required before the parentheses and vertical bars: the first backslash quotes the following backslash in Emacs; and the second indicates that the following character, the parenthesis or the vertical bar, is special.

But what does the vertical bar "|" mean?

  • Please don't use tag elisp, except for questions about the nature of the language itself, as opposed to, for example, other Lisp dialects. – Drew Mar 18 at 15:15

The vertical bar lets you form an alternation, a regular expression which matches any one of several alternatives. Combined with the parentheses, this one matches either the end of the line, or a tab character, or two space characters. See https://www.gnu.org/software/emacs/manual/html_mono/emacs.html#Regexps for details.

| improve this answer | |

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.