unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Jay Bingham" <b.jc-emacs@netzero.com>
Subject: RE: Storing regular expressions somewhere....
Date: Wed, 23 Aug 2006 18:29:06 GMT	[thread overview]
Message-ID: <20060823.113008.21820.634341@webmail10.nyc.untd.com> (raw)

On Wednesday, 23 August 2006 Birju Prajapati wrote:

> After digging around a bit, I found M-x regexp-builder. However, 
this
> doesn't seem to understand predefined character classes such as \s-
> and seems to have a different regexp syntax. Is this a bug or am I
> doing something wrong?

First, I assume that when you say regexp-builder your are actually 
referring to re-builder.el.
Although I am not an re-builder guru, I have used it quite a bit and 
I found it hard to believe that it did not understand the predefined 
character classes, so I tried it.  It works for me so you must be 
doing something wrong. ;-)

Before we get to what you could be doing wrong lets talk about what 
you mean when you say that it has a different regexp syntax.  Do you 
mean that in the default input syntax, escape characters 
(backslashes) must be doubled and double quotes must be escaped, 
which means that regular expressions generated with this syntax 
cannot be used in the interactive commands: isearch-forward-regexp, 
query-replace-regexp and replace-regexp?

Carefully reading of the commentary in re-builder reveals that there 
are four forms of input syntax provided by re-builder:
 'read', 'string', 'sregex' and 'lisp-re'
The default input syntax form is: 'read'
The syntax used by the 'read' form is the syntax that is used in the 
arguments of functions like re-search-forward and re-search-backward, 
which are used when an e-lisp function that does searching is 
written.  This syntax requires that escape characters and double 
quotes be escaped.
The syntax used by the 'string' form is the syntax that is used by 
the interactive functions isearch-forward-regexp, query-replace-
regexp and replace-regexp.
As stated in the commentary, "With the `string' syntax there's no 
need to escape the backslashes and double quotes simplifying the 
editing somewhat."  
Regarding the other two input forms the commentary states: "The other 
two allow editing of symbolic regular expressions supported by the 
packages of the same name.  (`lisp-re' is a package by me and its 
support may go away as it is nearly the same as the `sregex' package 
in Emacs)."  (I am not familiar with either of these packages and I 
don't believe that they pertain to your situation so that is all that 
will be said about them).

Now that we have that out of the way, I suspect that what you were 
doing wrong was trying to use 'string' syntax in 'read' syntax mode.

Here is a regexp that I created while reading the re-builder 
commentary after changing to string syntax (C-c C-i string RET):
 c\sw+?\(r\|w\)\w+\s-
It matches 31 strings and the space that follows them in the re-
builder.el file.
This regexp matches 268 words and the space that follows them in the 
re-builder.el file:
 \b\sw+?\(r\|w\)\w+\s-

With the above regexp in the RE-Builder buffer when I change 
from 'string' to 'read' syntax the regexp changes to the following:
\\b\\sw+?\\(r\\|w\\)\\w+\\s-
Changing back to 'string' syntax restores the regexp to its former 
value.

Good luck and thanks for the opportunity to learn more about re-
builder.
__
J_)
C_)ingham 


_____________________________________________________________________
PrivatePhone - FREE telephone number & voicemail.
A number so private, you can make it public.
http://www.privatephone.com

             reply	other threads:[~2006-08-23 18:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-23 18:29 Jay Bingham [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-08-23 14:05 Storing regular expressions somewhere Birju Prajapati
2006-08-23 15:10 ` Birju Prajapati
2006-08-23 15:27 ` Drew Adams
     [not found] ` <mailman.5508.1156345825.9609.help-gnu-emacs@gnu.org>
2006-08-23 15:45   ` Johan Bockgård

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=20060823.113008.21820.634341@webmail10.nyc.untd.com \
    --to=b.jc-emacs@netzero.com \
    /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).