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

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

Re: Converting a non-escaped regexp to an escaped version


From: Juanma Barranquero
Subject: Re: Converting a non-escaped regexp to an escaped version
Date: Thu, 7 Jun 2007 16:21:07 +0200

On 6/7/07, HippoMan <address@hidden> wrote:

1. Test a regular expression interactively, for example, via
   the use of M-x re-search-forward.

2. Assume that I finally decide that the following regexp is
   the one that I want to use within my elisp code:

     \bfoo\b.*:.*\bbar\([0-9]\{9\}quack\.quack\)\b

3. Put this regexp to the kill ring.

4. Use my proposed function to yank it into my elisp code
   (for example, within an invocation of `match-string'), as follows:

     \\bfoo\\b.*:.*\\bbar\\([0-9]\\{9\\}quack\\.quack\\)\\b

You could use M-x re-builder to test your regexp, which is very nice,
supports several regexp syntaxes and can highlight subexpressions
(groups).

Then, inside the re-builder buffer, do C-c C-w (that's `reb-copy') to
copy the regexp.

            Juanma




reply via email to

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