help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: regexp problems the evil \[


From: Stefan Monnier
Subject: Re: regexp problems the evil \[
Date: Thu, 23 Mar 2017 18:05:09 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

>   (query-replace "\\[" "\\begin{displaymath}\n" nil)
     ^^^^^^^^^^^^^^^^^^^
     matches \[

>   (query-replace-regexp "\\[\\([^}]+\\)\\]" "@\\1" nil))
     ^^^^^^^^^^^^^^^^^^^^^^^^^
        matches [

Since [ in regexps has otherwise a special meaning.
To match \[ and \] you'll want

   (query-replace-regexp "\\\\\\[\\([^}]+\\)\\\\\\]" "@\\1" nil))


-- Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]