[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Transposing Regular Expression
From: |
LanX |
Subject: |
Re: Transposing Regular Expression |
Date: |
Wed, 11 Nov 2009 22:40:12 -0800 (PST) |
User-agent: |
G2/1.0 |
Hi
I'm a newbie in elisp, but this works for me:
--------- tested in M-x ielm
ELISP> (defun pl-tr (STRING FROM TO)
"perlish transpose"
(replace-regexp-in-string
(concat "\[" FROM "\]")
(lambda (s)
(string (elt TO (search s FROM))))
STRING)
)
pl-tr
ELISP> (pl-tr "fedcba" "bcd" "BCD")
"feDCBa"
-----------------------------------------------
HTH
Cheers
Rolf