From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: jrwats Newsgroups: gmane.emacs.help Subject: Transposing Regular Expression Date: Wed, 11 Nov 2009 09:25:26 -0800 (PST) Organization: http://groups.google.com Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1257963114 32343 80.91.229.12 (11 Nov 2009 18:11:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 11 Nov 2009 18:11:54 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 11 19:11:47 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1N8HfS-0001a7-3N for geh-help-gnu-emacs@m.gmane.org; Wed, 11 Nov 2009 19:11:42 +0100 Original-Received: from localhost ([127.0.0.1]:52645 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8HfR-00089X-GL for geh-help-gnu-emacs@m.gmane.org; Wed, 11 Nov 2009 13:11:41 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!postnews.google.com!x5g2000prf.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 16 Original-NNTP-Posting-Host: 71.227.232.135 Original-X-Trace: posting.google.com 1257960326 31034 127.0.0.1 (11 Nov 2009 17:25:26 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 11 Nov 2009 17:25:26 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: x5g2000prf.googlegroups.com; posting-host=71.227.232.135; posting-account=bFjqRgoAAAA1g2eFs8HouoaeO5EHoWR2 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.4) Gecko/20091028 Ubuntu/9.10 (karmic) Firefox/3.5.4,gzip(gfe),gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:174594 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:69669 Archived-At: 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 \#) ?