unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* force upper case of matched regex text pattern
@ 2008-03-13  3:12 xahlee
  2008-03-13  8:53 ` Andreas Röhler
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: xahlee @ 2008-03-13  3:12 UTC (permalink / raw)
  To: help-gnu-emacs

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

(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.

PS I wrote a tutorial on this

 http://xahlee.org/emacs/emacs_find_replace.html

  Xah
  xah@xahlee.org
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: force upper case of matched regex text pattern
  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 17:42 ` Niels Giesen
  2 siblings, 0 replies; 5+ messages in thread
From: Andreas Röhler @ 2008-03-13  8:53 UTC (permalink / raw)
  To: help-gnu-emacs

Am Donnerstag, 13. März 2008 04:12 schrieb xahlee@gmail.com:
> (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
>   )
> )
> 


Maybe I miss your point:

you should be able to write something like

(concat "<p>" (upcase obj))

where obj is `match-string'


Andreas Röhler




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: force upper case of matched regex text pattern
       [not found] ` <mailman.8825.1205398225.18990.help-gnu-emacs@gnu.org>
@ 2008-03-13 11:03   ` Xah
  0 siblings, 0 replies; 5+ messages in thread
From: Xah @ 2008-03-13 11:03 UTC (permalink / raw)
  To: help-gnu-emacs

Xah wrote:
 (buffer-substring (match-beginning 1) (match-end 1))

Andreas Röhler wrote:
 (match-string 1)

Thanks. That's much simpler.

  Xah
  xah@xahlee.org
∑ http://xahlee.org/

☄


On Mar 13, 1:53 am, Andreas Röhler <andreas.roeh...@online.de> wrote:
> Am Donnerstag, 13. März 2008 04:12 schrieb xah...@gmail.com:
>
> > (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
> >   )
> > )
>
> Maybe I miss your point:
>
> you should be able to write something like
>
> (concat "<p>" (upcase obj))
>
> where obj is `match-string'
>
> Andreas Röhler



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: force upper case of matched regex text pattern
  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 17:42 ` Niels Giesen
  2008-03-13 19:50   ` Xah Lee
  2 siblings, 1 reply; 5+ messages in thread
From: Niels Giesen @ 2008-03-13 17:42 UTC (permalink / raw)
  To: help-gnu-emacs

"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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: force upper case of matched regex text pattern
  2008-03-13 17:42 ` Niels Giesen
@ 2008-03-13 19:50   ` Xah Lee
  0 siblings, 0 replies; 5+ messages in thread
From: Xah Lee @ 2008-03-13 19:50 UTC (permalink / raw)
  To: help-gnu-emacs

Niels Giesen:
«C-M-% your_regexp RET <p>\,(upcase \1)

...
please rewrite it, because as you see, you can refer to (sub)matches
in the \,() environment ;)
»

That's what i was looking for!

Corrected. Thanks.

  Xah
  xah@xahlee.org
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-03-13 19:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2008-03-13 19:50   ` Xah Lee

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).