From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.help Subject: How to grok a complicated regex? Date: Fri, 13 Mar 2015 22:35:36 +0100 Message-ID: <87ioe4a8d3.fsf@wmi.amu.edu.pl> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1426282571 29477 80.91.229.3 (13 Mar 2015 21:36:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 13 Mar 2015 21:36:11 +0000 (UTC) To: Help Gnu Emacs mailing list Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Mar 13 22:36:05 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YWXFU-0005eN-4B for geh-help-gnu-emacs@m.gmane.org; Fri, 13 Mar 2015 22:36:04 +0100 Original-Received: from localhost ([::1]:38749 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWXFT-0005D3-B0 for geh-help-gnu-emacs@m.gmane.org; Fri, 13 Mar 2015 17:36:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50338) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWXFE-0005Al-Qg for help-gnu-emacs@gnu.org; Fri, 13 Mar 2015 17:35:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YWXFB-0007rf-Ld for help-gnu-emacs@gnu.org; Fri, 13 Mar 2015 17:35:48 -0400 Original-Received: from msg.wmi.amu.edu.pl ([2001:808:114:2::50]:45793) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWXFA-0007qK-Qq for help-gnu-emacs@gnu.org; Fri, 13 Mar 2015 17:35:45 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by msg.wmi.amu.edu.pl (Postfix) with ESMTP id 066895AA42 for ; Fri, 13 Mar 2015 22:35:43 +0100 (CET) Original-Received: from msg.wmi.amu.edu.pl ([127.0.0.1]) by localhost (msg.wmi.amu.edu.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 197deI3DPVGl for ; Fri, 13 Mar 2015 22:35:42 +0100 (CET) Original-Received: from localhost (117-116.echostar.pl [213.156.117.116]) by msg.wmi.amu.edu.pl (Postfix) with ESMTPSA id B2A385AA40 for ; Fri, 13 Mar 2015 22:35:42 +0100 (CET) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:808:114:2::50 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:103147 Archived-At: Hi all, so I have this monstrosity [note: I know, there are much worse ones, too!]: "\\`\\(?:\\\\[([]\\|\\$+\\)?\\(.*?\\)\\(?:\\\\[])]\\|\\$+\\)?\\'" (it's in the org-latex--script-size function in ox-latex.el, if you're curious). I'm not asking =E2=80=9Cwhat does this match=E2=80=9D =E2=80=93 I can rea= d it myself. But it comes with a considerable effort. Are you aware of any tools that might help to understand such regexen? I know about re-builder, but it=E2=80=99s well suited for constructing a = regex matching a given string, not the other way round. For instance, show-paren-mode does not really help here, since it seems to pair =E2=80=9C\\(=E2=80=9C with unescaped =E2=80=9C)=E2=80=9D. Any ideas? (Note: if there are no such tools, I might be tempted to craft one. Two things that come to my mind are proper highlighting of matching parens of various kinds and eldoc-like hints for all the regex constructs =E2=80= =93 I never seem to remember what does =E2=80=9C\\`=E2=80=9D do, for instance= . Also, displaying the string with single backslashes and not in the way it is actually typed in in Elisp, with all the backslash escaping, might be helpful. Would there be a demand for such a tool larger than one person?) Best, --=20 Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Faculty of Mathematics and Computer Science Adam Mickiewicz University