From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Niels Giesen Newsgroups: gmane.emacs.help Subject: Re: force upper case of matched regex text pattern Date: Thu, 13 Mar 2008 18:42:31 +0100 Organization: www.tudelft.nl Message-ID: <87prtyh660.fsf@gmail.com> References: <841e479a-000c-4962-90f9-d2c998547f60@e25g2000prg.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1205433660 28195 80.91.229.12 (13 Mar 2008 18:41:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 13 Mar 2008 18:41:00 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Mar 13 19:41:27 2008 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 1JZsMb-0004nr-2j for geh-help-gnu-emacs@m.gmane.org; Thu, 13 Mar 2008 19:41:13 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JZsM2-0007CD-3a for geh-help-gnu-emacs@m.gmane.org; Thu, 13 Mar 2008 14:40:38 -0400 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!feeder.news-service.com!txtfeed1.tudelft.nl!tudelft.nl!binfeed2.tudelft.nl!news2.tudelft.nl!not-for-mail Original-Newsgroups: gnu.emacs.help,comp.emacs User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) Cancel-Lock: sha1:4/nWPREM+2ko5rSVQ38xTF+kFrs= Original-X-Complaints-To: sysadmin@tudelft.nl Original-Lines: 46 Original-NNTP-Posting-Host: 132pc207.sshunet.nl (145.97.207.132) Original-NNTP-Posting-Date: Thu, 13 Mar 2008 18:42:38 +0100 Original-X-Trace: 6795347d9678e34c46a2114933 Original-Xref: shelby.stanford.edu gnu.emacs.help:157006 comp.emacs:96443 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:52382 Archived-At: "xahlee@gmail.com" 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 "

" m1 )) > returnText > ) > ) > > then use “\,(upcase-matched)” for the replacement text. so: C-M-% your_regexp RET \,(upcase

\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@xahlee.org > ∑ http://xahlee.org/ > > ☄ -- http://niels.kicks-ass.org