From: Jambunathan K <kjambunathan@gmail.com>
To: Cecil Westerhof <Cecil@decebal.nl>
Cc: help-gnu-emacs@gnu.org
Subject: Re: How to combine these two regular expressions
Date: Mon, 13 Aug 2012 00:14:16 +0530 [thread overview]
Message-ID: <877gt4j6gv.fsf@gmail.com> (raw)
In-Reply-To: <87d32w88fl.fsf@Compaq.site> (Cecil Westerhof's message of "Sun, 12 Aug 2012 16:57:18 +0200")
You should provide a human-readable description of what the regexes are
trying to do. Have you tried:
C-h f regexp-opt RET
Cecil Westerhof <Cecil@decebal.nl> writes:
> I was asked by someone for a regular expression that could combine
> several search patterns, so that a file only needs to be scanned ones
> and not several times. I was partly successful, but I still need two
> passes.
>
> I now have the following code:
> (defun dcbl-search-heading ()
> (interactive)
> (re-search-forward "\\(.
> \\)\\(
>
> \\)\\(.+
> \\)\\(
> ?.+
> \\)" nil t)
> (replace-match "\\1
> #heading#
> \\4"))
>
> (defun dcbl-search-heading2 ()
> (interactive)
> (re-search-forward "\\(.
> \\)\\(
> \\)\\(.+
> \\)\\(\\\(.+
> \\\)+\\)" nil t)
> (replace-match "\\1
> #heading#
> \\4"))
>
> Is there a way to combine those regular expressions to one?
>
> By the way, if the used expressions could be optimised, let me know. I
> do not make them often, thus maybe I do things sub-optimal here.
--
next prev parent reply other threads:[~2012-08-12 18:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-12 14:57 How to combine these two regular expressions Cecil Westerhof
2012-08-12 18:44 ` Jambunathan K [this message]
2012-08-13 14:08 ` Doug Lewan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877gt4j6gv.fsf@gmail.com \
--to=kjambunathan@gmail.com \
--cc=Cecil@decebal.nl \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).