From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.help Subject: Re: How to grok a complicated regex? Date: Thu, 19 Mar 2015 09:15:54 +0100 Message-ID: <87h9th8ksl.fsf@gnu.org> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1426752990 23961 80.91.229.3 (19 Mar 2015 08:16:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 19 Mar 2015 08:16:30 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Alan Mackenzie Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Mar 19 09:16:22 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 1YYVco-0006X4-H8 for geh-help-gnu-emacs@m.gmane.org; Thu, 19 Mar 2015 09:16:18 +0100 Original-Received: from localhost ([::1]:37662 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYVcn-0003Pp-Uw for geh-help-gnu-emacs@m.gmane.org; Thu, 19 Mar 2015 04:16:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43706) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYVcV-0003Js-1c for help-gnu-emacs@gnu.org; Thu, 19 Mar 2015 04:15:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YYVcR-0005gu-Rz for help-gnu-emacs@gnu.org; Thu, 19 Mar 2015 04:15:58 -0400 Original-Received: from deliver.uni-koblenz.de ([141.26.64.15]:34640) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYVcR-0005gg-Kz for help-gnu-emacs@gnu.org; Thu, 19 Mar 2015 04:15:55 -0400 Original-Received: from thinkpad-t440p (dhcp132.uni-koblenz.de [141.26.71.132]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by deliver.uni-koblenz.de (Postfix) with ESMTPSA id EDEA21A8488; Thu, 19 Mar 2015 09:15:54 +0100 (CET) Mail-Followup-To: Alan Mackenzie , help-gnu-emacs@gnu.org In-Reply-To: (Alan Mackenzie's message of "Wed, 18 Mar 2015 16:40:35 +0000 (UTC)") User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 141.26.64.15 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:103210 Archived-At: Alan Mackenzie writes: > I wrote myself the following tool. It's not production quality, but > you might find it useful nonetheless. To use it, Type > > M-: (pp-regexp re-horror). > > It displays the regexp at the end of the *scratch* buffer, dropping > the contents of any \(..\) construct by one line. Interesting idea, and it helps a bit. What would be really cool was a transformation from regexp to rx form. Oh, and that seems to exist already (available from Marmalade and MELPA)! https://github.com/joddie/pcre2el Example: --8<---------------cut here---------------start------------->8--- (rxt-elisp-to-rx "\\`\\(?:\\\\[([]\\|\\$+\\)?\\(.*?\\)\\(?:\\\\[])]\\|\\$+\\)?\\'") ;; Evals to... (seq bos (\? (or (seq "\\" (any "[" "(")) (+ "$"))) (submatch (*\? nonl)) (\? (or (seq "\\" (any ")" "]")) (+ "$"))) eos) --8<---------------cut here---------------end--------------->8--- Bye, Tassilo