[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reg-exp
From: |
David Forrest |
Subject: |
Re: Reg-exp |
Date: |
Thu, 22 Aug 2002 17:59:47 -0400 (EDT) |
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/
- Reg-exp, J. Thomas, 2002/08/22
- Re: Reg-exp,
David Forrest <=