all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Another regex problem
@ 2005-10-25 18:44 exits funnel
  0 siblings, 0 replies; 6+ messages in thread
From: exits funnel @ 2005-10-25 18:44 UTC (permalink / raw)


Hello,

I've bumped into another problem which I'd like to use
query-replace-regexp to fix if possible.  Not I've got
a bunch of these:

t_foo_Grape_Banana
t_foo_Pear
t_foo_Apple

which I'd like to replace with
t_foo_grape_banana
t_foo_pear
t_foo_apple

In other words I'd like to make them uniformly lower
case but I can't figure out how to accomplish this in
the replacement string.  Is it possible?  Thanks in
advance.

-exits


	
		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

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

* Re: Another regex problem
       [not found] <mailman.12658.1130265846.20277.help-gnu-emacs@gnu.org>
@ 2005-10-25 21:18 ` rgb
  2005-10-25 21:47 ` Pascal Bourguignon
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: rgb @ 2005-10-25 21:18 UTC (permalink / raw)


> In other words I'd like to make them uniformly lower
> case but I can't figure out how to accomplish this in
> the replacement string.

(setq case-fold-search t
      case-replace nil)

Specify both the search text and replacement in lower case.
With case-fold-search t it will find upper and camel case
occurances.  case-replace nil causes the replacement to be
used literally.

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

* RE: Another regex problem
@ 2005-10-25 21:28 Dave Humphries
  0 siblings, 0 replies; 6+ messages in thread
From: Dave Humphries @ 2005-10-25 21:28 UTC (permalink / raw)


How about a keyboard macro: search-forward to t_foo_ then move point to
end of line and downcase-region. 

-----Original Message-----
From: help-gnu-emacs-bounces+dave.humphries=dytech.com.au@gnu.org
[mailto:help-gnu-emacs-bounces+dave.humphries=dytech.com.au@gnu.org] On
Behalf Of exits funnel
Sent: Wednesday, 26 October 2005 5:44 AM
To: help-gnu-emacs@gnu.org
Subject: Another regex problem

Hello,

I've bumped into another problem which I'd like to use
query-replace-regexp to fix if possible.  Not I've got a bunch of these:

t_foo_Grape_Banana
t_foo_Pear
t_foo_Apple

which I'd like to replace with
t_foo_grape_banana
t_foo_pear
t_foo_apple

In other words I'd like to make them uniformly lower case but I can't
figure out how to accomplish this in the replacement string.  Is it
possible?  Thanks in advance.

-exits


	
		
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com


_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

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

* Re: Another regex problem
       [not found] <mailman.12658.1130265846.20277.help-gnu-emacs@gnu.org>
  2005-10-25 21:18 ` rgb
@ 2005-10-25 21:47 ` Pascal Bourguignon
  2005-10-25 22:06 ` David Kastrup
  2005-10-27 21:42 ` Edward Dodge
  3 siblings, 0 replies; 6+ messages in thread
From: Pascal Bourguignon @ 2005-10-25 21:47 UTC (permalink / raw)


exits funnel <exitsfunnel@yahoo.com> writes:

> Hello,
>
> I've bumped into another problem which I'd like to use
> query-replace-regexp to fix if possible.  Not I've got
> a bunch of these:
>
> t_foo_Grape_Banana
> t_foo_Pear
> t_foo_Apple
>
> which I'd like to replace with
> t_foo_grape_banana
> t_foo_pear
> t_foo_apple
>
> In other words I'd like to make them uniformly lower
> case but I can't figure out how to accomplish this in
> the replacement string.  Is it possible?  Thanks in
> advance.

If you must downcase only part of the substitution, I don't know other
ways than to write some emacs lisp, or awk.  Something like:

(while (re-search-forward regexp nil t)
   (let ((p1 (match-string 1))
         (p2 (match-string 2))
         ...
         (pn (match-string n)))
    (delete-region (match-beginning) (match-end))
    (insert (format "...%s...%s...%s..." p1 (downcase p2) ... pn))))



Anyways, if you like to process flex/bison (or lex/yacc) files like
this, it may be a good idea not to make it a one-shoot affair, but to
keep the transformation in a script or a Makefile.  In general when I
use flex/bison, I've got a number of pre and post processing of the
sources in Makefile, with sed & awk.  For more sophisticated
transformations, emacs could be used (in batch mode ;-).

-- 
"A TRUE Klingon warrior does not comment his code!"

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

* Re: Another regex problem
       [not found] <mailman.12658.1130265846.20277.help-gnu-emacs@gnu.org>
  2005-10-25 21:18 ` rgb
  2005-10-25 21:47 ` Pascal Bourguignon
@ 2005-10-25 22:06 ` David Kastrup
  2005-10-27 21:42 ` Edward Dodge
  3 siblings, 0 replies; 6+ messages in thread
From: David Kastrup @ 2005-10-25 22:06 UTC (permalink / raw)


exits funnel <exitsfunnel@yahoo.com> writes:

> Hello,
>
> I've bumped into another problem which I'd like to use
> query-replace-regexp to fix if possible.  Not I've got
> a bunch of these:
>
> t_foo_Grape_Banana
> t_foo_Pear
> t_foo_Apple
>
> which I'd like to replace with
> t_foo_grape_banana
> t_foo_pear
> t_foo_apple
>
> In other words I'd like to make them uniformly lower
> case but I can't figure out how to accomplish this in
> the replacement string.  Is it possible?  Thanks in
> advance.

Well, with a developer Emacs, you can use

C-M-% t_foo_[_a-zA-Z]+ RET \,(downcase \&) RET

\, is one of the things that I find pretty convenient.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: Another regex problem
       [not found] <mailman.12658.1130265846.20277.help-gnu-emacs@gnu.org>
                   ` (2 preceding siblings ...)
  2005-10-25 22:06 ` David Kastrup
@ 2005-10-27 21:42 ` Edward Dodge
  3 siblings, 0 replies; 6+ messages in thread
From: Edward Dodge @ 2005-10-27 21:42 UTC (permalink / raw)


exits funnel <exitsfunnel@yahoo.com> writes:

> Hello,
> 
> I've bumped into another problem which I'd like to use
> query-replace-regexp to fix if possible.  Not I've got
> a bunch of these:
> 
> t_foo_Grape_Banana
> t_foo_Pear
> t_foo_Apple
> 
> which I'd like to replace with
> t_foo_grape_banana
> t_foo_pear
> t_foo_apple
> 
> In other words I'd like to make them uniformly lower
> case but I can't figure out how to accomplish this in
> the replacement string.  is it possible?  thanks in
> advance.
> 
> -exits

C-x C-l downcase-region 

-- 
Edward Dodge
          
   __o    
 _`\(,_   
(_)/ (_)  ---  --- 

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

end of thread, other threads:[~2005-10-27 21:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-25 18:44 Another regex problem exits funnel
     [not found] <mailman.12658.1130265846.20277.help-gnu-emacs@gnu.org>
2005-10-25 21:18 ` rgb
2005-10-25 21:47 ` Pascal Bourguignon
2005-10-25 22:06 ` David Kastrup
2005-10-27 21:42 ` Edward Dodge
  -- strict thread matches above, loose matches on Subject: below --
2005-10-25 21:28 Dave Humphries

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.