[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Operate on region string
From: |
robert . thorpe |
Subject: |
Re: Operate on region string |
Date: |
20 Sep 2006 03:14:49 -0700 |
User-agent: |
G2/1.0 |
Hadron Quark wrote:
> Tassilo Horn <heimdall@uni-koblenz.de> writes:
>
> > Hadron Quark <hadronquark@gmail.com> writes:
> >
> > Hi Hadron,
> >
> >> I want something like this to work on a buffer region
> >>
> >> (defun remove-vowels-region(te)
> >> "Remove the vowels"
> >> (interactive "sTe:")
> >> (replace-regexp-in-string "[aeiouAEIOU]" "" te)
> >> )
> >
> > Try that:
> >
> > (defun remove-vowels-region (start end)
> > (interactive "r")
> > (replace-regexp "[aeiouAEIOU]" "" nil start end))
> >
> > Bye,
> > Tassilo
>
> vn shrtr nd swtr!
>
> (even shorter and sweeter)
As a sidenote, you look at the problem like this:
* Is there a function that works on a region I can use for my purpose.
If so it is simple like the above.
* If not, maybe there is a function that works on the whole region. In
this case I can use M-x widen and M-x narrow-to-region to perform an
action on a region.
* If that doesn't work (which is very unlikely) then convert the region
to a string and operate on the string.
- Re: Operate on region string, (continued)