all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Transposing Regular Expression
@ 2009-11-11 17:25 jrwats
  2009-11-11 20:51 ` harven
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: jrwats @ 2009-11-11 17:25 UTC (permalink / raw)
  To: help-gnu-emacs

Perl provides the transpose operator:
=~ tr/abc/xyz/	not really a regular expression, but exchanges 'x' for
'a', 'y' for 'b', and 'z' for 'c' in the source string.

My question is how to accomplish this in emacs.  When only needing to
tranpose 2 characters that need to replace each other, (the equivalent
perl expression woud be =~ tr/ab/ba/ as an example, I could simply
regexp replace 'a' with a unique letter or symbol, maybe '$' for
instance, then replace all b's with a's and all $'s with b's.  This
obviously becomes unweildy after we start transposing more than 2
characters.  My question is, now that emacs provides fancy regexp
replace clauses: \# for the number match, and arbitrary lisp
expressions \,(some-lisp), etc, is there a way to accomplish this in
one fell swoop via a very crazy regular expression find-replace?  Also
is there a list of meaningful  regular expression search escape
characters somewhere (like \#) ?


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

end of thread, other threads:[~2009-11-17  2:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-11 17:25 Transposing Regular Expression jrwats
2009-11-11 20:51 ` harven
2009-11-11 21:45 ` Andreas Politz
2009-11-12  6:40 ` LanX
2009-11-16 12:16 ` Andreas Röhler
     [not found] ` <mailman.10804.1258373854.2239.help-gnu-emacs@gnu.org>
2009-11-16 16:28   ` jrwats
2009-11-17  2:13     ` LanX

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.