unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Niels Giesen <niels.giesen@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: force upper case of matched regex text pattern
Date: Thu, 13 Mar 2008 18:42:31 +0100	[thread overview]
Message-ID: <87prtyh660.fsf@gmail.com> (raw)
In-Reply-To: 841e479a-000c-4962-90f9-d2c998547f60@e25g2000prg.googlegroups.com

"xahlee@gmail.com" <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 "<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@xahlee.org
> ∑ http://xahlee.org/
>
> ☄

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


  parent reply	other threads:[~2008-03-13 17:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-13  3:12 force upper case of matched regex text pattern xahlee
2008-03-13  8:53 ` Andreas Röhler
     [not found] ` <mailman.8825.1205398225.18990.help-gnu-emacs@gnu.org>
2008-03-13 11:03   ` Xah
2008-03-13 17:42 ` Niels Giesen [this message]
2008-03-13 19:50   ` Xah Lee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87prtyh660.fsf@gmail.com \
    --to=niels.giesen@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).