unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Regexp Query/Replace Without Trashing Original Text
@ 2004-07-31 10:37 Tennis Smith
  2004-08-01 13:15 ` Kai Grossjohann
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Tennis Smith @ 2004-07-31 10:37 UTC (permalink / raw)


Hi,

How can I convert something like this

$GLOBAL_VAR

to this:

$global_array(GLOBAL_VAR)

??

Its easy to do a regexp query/replace for "\$[A-Z]", but I don't really want
to change either the leading dollar sign ("$") or the trailing uppercase
text (GLOBAL_VAR).

TIA,
-Tennis

--
Remove "-remove-to-reply" to respond to my  email address directly.

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

* Re: Regexp Query/Replace Without Trashing Original Text
  2004-07-31 10:37 Regexp Query/Replace Without Trashing Original Text Tennis Smith
@ 2004-08-01 13:15 ` Kai Grossjohann
  2004-08-01 17:34 ` Pascal Bourguignon
  2004-08-02 14:56 ` Yair Friedman
  2 siblings, 0 replies; 5+ messages in thread
From: Kai Grossjohann @ 2004-08-01 13:15 UTC (permalink / raw)


"Tennis Smith" <tennis_smith@yahoo-remove-to-reply.com> writes:

> How can I convert something like this
>
> $GLOBAL_VAR
>
> to this:
>
> $global_array(GLOBAL_VAR)
>
> ??

I presume it's variables starting with an uppercase letter.  You can
make a kbd macro for this.  C-x ( starts recording, C-x ) ends
recording.  In the macro, search for $ followed by an uppercase
letter.  Then move point to after the $, then insert "global_array(",
then use M-f or C-M-f to skip forward over the variable name, then
insert the closing parenthesis.

Kbd macros are your friends.

Kai

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

* Re: Regexp Query/Replace Without Trashing Original Text
  2004-07-31 10:37 Regexp Query/Replace Without Trashing Original Text Tennis Smith
  2004-08-01 13:15 ` Kai Grossjohann
@ 2004-08-01 17:34 ` Pascal Bourguignon
  2004-08-02  2:45   ` Tennis Smith
  2004-08-02 14:56 ` Yair Friedman
  2 siblings, 1 reply; 5+ messages in thread
From: Pascal Bourguignon @ 2004-08-01 17:34 UTC (permalink / raw)


"Tennis Smith" <tennis_smith@yahoo-remove-to-reply.com> writes:

> Hi,
> 
> How can I convert something like this
> 
> $GLOBAL_VAR
> 
> to this:
> 
> $global_array(GLOBAL_VAR)
> 
> ??
> 
> Its easy to do a regexp query/replace for "\$[A-Z]", but I don't really want
> to change either the leading dollar sign ("$") or the trailing uppercase
> text (GLOBAL_VAR).

M-x replace-regexp RET \$\([A-Z][A-Z_]*\) RET $global_array(\1) RET

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

There is no worse tyranny than to force a man to pay for what he does not
want merely because you think it would be good for him. -- Robert Heinlein

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

* Re: Regexp Query/Replace Without Trashing Original Text
  2004-08-01 17:34 ` Pascal Bourguignon
@ 2004-08-02  2:45   ` Tennis Smith
  0 siblings, 0 replies; 5+ messages in thread
From: Tennis Smith @ 2004-08-02  2:45 UTC (permalink / raw)


Thanks.

-T
"Pascal Bourguignon" <spam@thalassa.informatimago.com> wrote in message
news:877jsi3gpu.fsf@thalassa.informatimago.com...
> "Tennis Smith" <tennis_smith@yahoo-remove-to-reply.com> writes:
>
> > Hi,
> >
> > How can I convert something like this
> >
> > $GLOBAL_VAR
> >
> > to this:
> >
> > $global_array(GLOBAL_VAR)
> >
> > ??
> >
> > Its easy to do a regexp query/replace for "\$[A-Z]", but I don't really
want
> > to change either the leading dollar sign ("$") or the trailing uppercase
> > text (GLOBAL_VAR).
>
> M-x replace-regexp RET \$\([A-Z][A-Z_]*\) RET $global_array(\1) RET
>
> --
> __Pascal Bourguignon__                     http://www.informatimago.com/
>
> There is no worse tyranny than to force a man to pay for what he does not
> want merely because you think it would be good for him. -- Robert Heinlein

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

* Re: Regexp Query/Replace Without Trashing Original Text
  2004-07-31 10:37 Regexp Query/Replace Without Trashing Original Text Tennis Smith
  2004-08-01 13:15 ` Kai Grossjohann
  2004-08-01 17:34 ` Pascal Bourguignon
@ 2004-08-02 14:56 ` Yair Friedman
  2 siblings, 0 replies; 5+ messages in thread
From: Yair Friedman @ 2004-08-02 14:56 UTC (permalink / raw)


On Sat, 31 Jul 2004 03:37:48 -0700, 
"Tennis Smith" <tennis_smith@yahoo-remove-to-reply.com> writes:

> Hi,
>
> How can I convert something like this
>
> $GLOBAL_VAR
>
> to this:
>
> $global_array(GLOBAL_VAR)
>
> ??
>
> Its easy to do a regexp query/replace for "\$[A-Z]", but I don't really want
> to change either the leading dollar sign ("$") or the trailing uppercase
> text (GLOBAL_VAR).

You want to replace "\$\([A-Z_]+\)" with "$global_array(\1)", but as
Kai suggested keyboard macros are more easy most of the time.

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

end of thread, other threads:[~2004-08-02 14:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-31 10:37 Regexp Query/Replace Without Trashing Original Text Tennis Smith
2004-08-01 13:15 ` Kai Grossjohann
2004-08-01 17:34 ` Pascal Bourguignon
2004-08-02  2:45   ` Tennis Smith
2004-08-02 14:56 ` Yair Friedman

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