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

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

Re: How to grok a complicated regex?


From: Vaidheeswaran C
Subject: Re: How to grok a complicated regex?
Date: Mon, 23 Mar 2015 17:48:41 +0530
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.3.0

On Saturday 14 March 2015 03:05 AM, Marcin Borkowski wrote:
> 
> "\\`\\(?:\\\\[([]\\|\\$+\\)?\\(.*?\\)\\(?:\\\\[])]\\|\\$+\\)?\\'"
> 
> (it's in the org-latex--script-size function in ox-latex.el, if you're
> curious).
> 
> I'm not asking “what does this match” – I can read it myself.  But it
> comes with a considerable effort.  Are you aware of any tools that might
> help to understand such regexen?

Get xr.el from
http://debbugs.gnu.org/cgi/bugreport.cgi?msg=40;filename=xr.el;att=1;bug=13369

M-x load-library xr.el

M-x pp-eval-expression RET
(xr "\\`\\(?:\\\\[([]\\|\\$+\\)?\\(.*?\\)\\(?:\\\\[])]\\|\\$+\\)?\\'") RET

    (seq bos
         (opt
          (or
           (seq "\\"
                (any "[" "("))
           (one-or-more "$")))
         (group
          (minimal-match
           (zero-or-more nonl)))
         (opt
          (or
           (seq "\\"
                (any ")" "]"))
           (one-or-more "$")))
         eos)


There is also lex (see http://elpa.gnu.org/packages/lex.html) which
provides similar functionality.  FWIW, my edit window "disappears" if
I do

(lex-parse-re
"\\`\\(?:\\\\[([]\\|\\$+\\)?\\(.*?\\)\\(?:\\\\[])]\\|\\$+\\)?\\'")




reply via email to

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