all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Reg-exp
@ 2002-08-22 21:08 J. Thomas
  2002-08-22 21:59 ` Reg-exp David Forrest
  0 siblings, 1 reply; 2+ messages in thread
From: J. Thomas @ 2002-08-22 21:08 UTC (permalink / raw)



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).


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Reg-exp
  2002-08-22 21:08 Reg-exp J. Thomas
@ 2002-08-22 21:59 ` David Forrest
  0 siblings, 0 replies; 2+ messages in thread
From: David Forrest @ 2002-08-22 21:59 UTC (permalink / raw)
  Cc: help-gnu-emacs

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/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-08-22 21:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-22 21:08 Reg-exp J. Thomas
2002-08-22 21:59 ` Reg-exp David Forrest

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.