From: David Forrest <drf5n@mug.sys.virginia.edu>
Cc: <help-gnu-emacs@gnu.org>
Subject: Re: Reg-exp
Date: Thu, 22 Aug 2002 17:59:47 -0400 (EDT) [thread overview]
Message-ID: <Pine.LNX.4.33.0208221751070.1160-100000@mug.sys.virginia.edu> (raw)
In-Reply-To: <Pine.LNX.4.44.0208221359020.22078-100000@mos2.csde.washington.edu>
On Thu, 22 Aug 2002, J. Thomas wrote:
>
> I'm interested in doing a query search and replace for a regular
> expression that goes something like this:
>
> 1. find a particular string (e.g. "test") followed by any 3 random
>
> characters or numbers (e.g. "test100", "test234", "test_al")
>
> 2. replace an occurence with the random 3 characters/numbers followed by
>
> "test" (e.g. "100test", "234test", "_altest).
I would try:
M-x query-replace-regexp
\(test\)\([0-9a-zA-Z_]+\)
\2\1
the \( \) pair defines groups which are refered to as \1 and \2 in the
replacement. This doesn't do the exact 3 that you want, but I don't know
if emacs has a bounding operator like {3} or {2,4} so if the 'one or more'
operator '+' wont do what you want, you could do the repeat manually:
\(test\)\([0-9a-zA-Z_][0-9a-zA-Z_][0-9a-zA-Z_]\)
>
>
> How would I go about doing this?
>
> Thanks,
> jt
>
>
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> Jason Thomas
> Graduate Student
> Dept. of Sociology
> University of Washington, Seattle
> method@u.washington.edu
> http://students.washington.edu/~method
>
>
>
>
> _______________________________________________
> Help-gnu-emacs mailing list
> Help-gnu-emacs@gnu.org
> http://mail.gnu.org/mailman/listinfo/help-gnu-emacs
>
--
Dave Forrest drf5n@virginia.edu
(804)642-0662h (434)924-3954w http://mug.sys.virginia.edu/~drf5n/
prev parent reply other threads:[~2002-08-22 21:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-22 21:08 Reg-exp J. Thomas
2002-08-22 21:59 ` David Forrest [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.33.0208221751070.1160-100000@mug.sys.virginia.edu \
--to=drf5n@mug.sys.virginia.edu \
--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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.