0

This webpage recommends being in the string mode when using re-builder, the interactive regexp builder, where one does not have to use "\" to escape special characters.

But how does one convert newline and tab characters in, say, this regexp "\\([^\n\t '()\"]*\\)" in read mode to string mode? This question also applies to all characters that becomes special characters after the backslash.

  • You can directly use C-q tab and C-q C-j instead of \t and \n, respectively. – Tobias Feb 28 '18 at 10:24
1

how does one convert newline and tab characters

Just type them.

  • RET types a newline
  • TAB types a tab

This question also applies to all characters that becomes special characters after the backslash.

If there is no special regexp syntax for a character, then you match it by typing that character, or otherwise entering it literally. As has been mentioned by others, quoted-insert can be helpful here.

You can also let re-builder do it for you. When you switch between read and string syntax, the existing regexp is converted appropriately.

2

Type them as usual with TAB and RET (or C-j), if Emacs doesn't insert the corresponding characters for you, try C-q TAB and C-q C-j instead (Note that C-q runs the quoted-insert command).

  • 1
    It is a good idea to use C-q TAB instead of TAB because in some situation TAB is replaced by spaces (e.g., indentation). – Tobias Feb 28 '18 at 10:25

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.