gnu.emacs.help
[Top] [All Lists]

Re: force upper case of matched regex text pattern

Subject: Re: force upper case of matched regex text pattern
From: Niels Giesen
Date: Thu, 13 Mar 2008 18:42:31 +0100
Newsgroups: gnu.emacs.help, comp.emacs

"xahlee@xxxxxxxxx" <xahlee@xxxxxxxxx> writes:

> is there a way to force to upper case of a matched regex text pattern?
>

C-M-% your_regexp RET \,(upcase \num_of_match)

> (i recall having seen it somewhere)
>
> Currently, what i'm doing is to write my own replacement function that
> change the case like this:
>
> (defun upcase-matched ()
>   "Returns the upcase of matched text."
>   (let (m1 returnText)
>     (setq m1 (upcase (buffer-substring (match-beginning 1) (match-end
> 1))))
>     (setq returnText (concat "<p>" m1 ))
>     returnText
>   )
> )
>
> then use â\,(upcase-matched)â for the replacement text.

so:

C-M-% your_regexp RET \,(upcase <p>\0) 

...for instance

>
> PS I wrote a tutorial on this
>
>  http://xahlee.org/emacs/emacs_find_replace.html

please rewrite it, because as you see, you can refer to (sub)matches in the
\,() environment ;)
>
>   Xah
>   xah@xxxxxxxxxx
> â http://xahlee.org/
>
> â

-- 
http://niels.kicks-ass.org

<Prev in Thread] Current Thread [Next in Thread>