* case change in replacement text with regex-replace
@ 2007-04-11 11:31 Le TeXnicien de Surface
2007-04-14 20:01 ` Dieter Wilhelm
[not found] ` <mailman.2074.1176581215.7795.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 11+ messages in thread
From: Le TeXnicien de Surface @ 2007-04-11 11:31 UTC (permalink / raw)
To: help-gnu-emacs
hello
I capture text with the following regexp "\([^"]*\)"
and I would like the following:
if AB is the captured text, the replacement text is: AB ab Ab aB.
Is there any means to achieve that with query-replace-regexp?
Many thanks in advance for any hint.
--
Le TeXnicien de Surface
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: case change in replacement text with regex-replace
2007-04-11 11:31 case change in replacement text with regex-replace Le TeXnicien de Surface
@ 2007-04-14 20:01 ` Dieter Wilhelm
[not found] ` <mailman.2074.1176581215.7795.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 11+ messages in thread
From: Dieter Wilhelm @ 2007-04-14 20:01 UTC (permalink / raw)
To: Le TeXnicien de Surface; +Cc: help-gnu-emacs
Le TeXnicien de Surface <texnicien.de.surface@chezmoi.eur> writes:
> I capture text with the following regexp "\([^"]*\)"
> and I would like the following:
> if AB is the captured text, the replacement text is: AB ab Ab aB.
I do not understand, your regexp catches all chars (including
newlines) except `"' and your example has only two chars?
--
Best wishes
H. Dieter Wilhelm
Darmstadt, Germany
^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <mailman.2074.1176581215.7795.help-gnu-emacs@gnu.org>]
* Re: case change in replacement text with regex-replace
[not found] ` <mailman.2074.1176581215.7795.help-gnu-emacs@gnu.org>
@ 2007-04-15 8:22 ` Le TeXnicien de Surface
2007-04-15 23:10 ` Dieter Wilhelm
[not found] ` <mailman.2109.1176678953.7795.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 11+ messages in thread
From: Le TeXnicien de Surface @ 2007-04-15 8:22 UTC (permalink / raw)
To: help-gnu-emacs
Dieter Wilhelm écrivait :
> Le TeXnicien de Surface <texnicien.de.surface@chezmoi.eur> writes:
>
>> I capture text with the following regexp "\([^"]*\)"
>> and I would like the following:
>> if AB is the captured text, the replacement text is: AB ab Ab aB.
>
> I do not understand, your regexp catches all chars (including
> newlines) except `"' and your example has only two chars?
First of all, many thanks for the answer.
It seems that I was anything but clear so I will try to restate my question:
I know I will obtain a string of two characters (the capturing regexp is in
fact immaterial) and what I would like to obtain from, say, AB is the
string `AB ab Ab aB' as previously stated. I could even easily capture two
strings of one character each. So, in a nutshell: How do we change the case
of a character, previously captured, in the replacement string? Is there
anything as the perl \U to be used in the replacement part of a
regex-search and replace?
Many thanks in advance for any hint
--
Le TeXnicien de Surface
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: case change in replacement text with regex-replace
2007-04-15 8:22 ` Le TeXnicien de Surface
@ 2007-04-15 23:10 ` Dieter Wilhelm
2007-04-15 23:21 ` Dieter Wilhelm
[not found] ` <mailman.2110.1176679588.7795.help-gnu-emacs@gnu.org>
[not found] ` <mailman.2109.1176678953.7795.help-gnu-emacs@gnu.org>
1 sibling, 2 replies; 11+ messages in thread
From: Dieter Wilhelm @ 2007-04-15 23:10 UTC (permalink / raw)
To: Le TeXnicien de Surface; +Cc: help-gnu-emacs
Le TeXnicien de Surface <texnicien.de.surface@chezmoi.eur> writes:
> I know I will obtain a string of two characters (the capturing regexp is in
> fact immaterial) and what I would like to obtain from, say, AB is the
> string `AB ab Ab aB' as previously stated. I could even easily capture two
> strings of one character each. So, in a nutshell: How do we change the case
> of a character, previously captured, in the replacement string? Is there
> anything as the perl \U to be used in the replacement part of a
\U I didn't see in the elisp manual
> regex-search and replace?
I'd try it with the \, command with replace-regexp though
(info "(emacs) Regexp Replace") <- put cursor behind parenthesis and
type C-x C-e. The following is just an idea, I didn't check it. I
assume you must also make the search and replace command case
sensitive.
IDEA: \(.\)\(.\) -> \,(concat (upcase \1)(downcase \2) " " (...))
--
Best wishes
H. Dieter Wilhelm
Darmstadt, Germany
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: case change in replacement text with regex-replace
2007-04-15 23:10 ` Dieter Wilhelm
@ 2007-04-15 23:21 ` Dieter Wilhelm
[not found] ` <mailman.2110.1176679588.7795.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 11+ messages in thread
From: Dieter Wilhelm @ 2007-04-15 23:21 UTC (permalink / raw)
To: Le TeXnicien de Surface; +Cc: help-gnu-emacs
Dieter Wilhelm <dieter@duenenhof-wilhelm.de> writes:
> I'd try it with the \, command with replace-regexp though
>
> (info "(emacs) Regexp Replace") <- put cursor behind parenthesis and
> type C-x C-e. The following is just an idea, I didn't check it. I
> assume you must also make the search and replace command case
> sensitive.
>
> IDEA: \(.\)\(.\) -> \,(concat (upcase \1)(downcase \2) " " (...))
Why so complicated? Maybe the solution to your problem is solvable
with a simple keyboard macro?
--
Best wishes
H. Dieter Wilhelm
Darmstadt, Germany
^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <mailman.2110.1176679588.7795.help-gnu-emacs@gnu.org>]
* Re: case change in replacement text with regex-replace [solved]
[not found] ` <mailman.2110.1176679588.7795.help-gnu-emacs@gnu.org>
@ 2007-04-16 6:56 ` Le TeXnicien de Surface
2007-04-16 19:50 ` Dieter Wilhelm
0 siblings, 1 reply; 11+ messages in thread
From: Le TeXnicien de Surface @ 2007-04-16 6:56 UTC (permalink / raw)
To: help-gnu-emacs
Dieter Wilhelm écrivait :
> Dieter Wilhelm <dieter@duenenhof-wilhelm.de> writes:
>
>> I'd try it with the \, command with replace-regexp though
>>
>> (info "(emacs) Regexp Replace") <- put cursor behind parenthesis and
>> type C-x C-e. The following is just an idea, I didn't check it. I
>> assume you must also make the search and replace command case
>> sensitive.
>>
>> IDEA: \(.\)\(.\) -> \,(concat (upcase \1)(downcase \2) " " (...))
Well, thanks a lot for showing me the way out!
I succeeded with query-replace-regexp-eval
and the following
(I must say here that the text I work with is in the form « c="AB" »
and that I want to obtain « c="AB" or c="Ab" or c="aB" or c="ab" » from it)
Here the searching regexp « c="\([A-Z\)\([A-Z]\)" »
and here the expression evaluated
(concat "c=\"" (upcase \1) (upcase \2) "\" or c= \"" (upcase \1)
(downcase \2) "\" or c= \"" (downcase \1) (upcase \2)
"\" or c= \"" (downcase \1) (downcase \2) "\"")
hih :)
--
Le TeXnicien de Surface
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: case change in replacement text with regex-replace [solved]
2007-04-16 6:56 ` case change in replacement text with regex-replace [solved] Le TeXnicien de Surface
@ 2007-04-16 19:50 ` Dieter Wilhelm
0 siblings, 0 replies; 11+ messages in thread
From: Dieter Wilhelm @ 2007-04-16 19:50 UTC (permalink / raw)
To: Le TeXnicien de Surface; +Cc: help-gnu-emacs
Le TeXnicien de Surface <texnicien.de.surface@chezmoi.eur> writes:
>
> I succeeded with query-replace-regexp-eval
> and the following
> (I must say here that the text I work with is in the form « c="AB" »
> and that I want to obtain « c="AB" or c="Ab" or c="aB" or c="ab" » from it)
>
> Here the searching regexp « c="\([A-Z\)\([A-Z]\)" »
> and here the expression evaluated
>
> (concat "c=\"" (upcase \1) (upcase \2) "\" or c= \"" (upcase \1)
> (downcase \2) "\" or c= \"" (downcase \1) (upcase \2)
> "\" or c= \"" (downcase \1) (downcase \2) "\"")
Great, but I think a macro would have been a good alternative.
I would have written this profound message to your private mail
address but I'm getting constantly this 8-):
texnicien.de.surface@chezmoi.eur
SMTP error from remote mail server after RCPT TO:<texnicien.de.surface@chezmoi.eur>:
host authmailonline.kundenserver.de [212.227.15.180]:
550 texnicien.de.surface@chezmoi.eur: no such domain
--
Best wishes
H. Dieter Wilhelm
Darmstadt, Germany
^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <mailman.2109.1176678953.7795.help-gnu-emacs@gnu.org>]
* Re: case change in replacement text with regex-replace
[not found] ` <mailman.2109.1176678953.7795.help-gnu-emacs@gnu.org>
@ 2007-04-17 23:47 ` Johan Bockgård
2007-04-18 5:19 ` Dieter Wilhelm
[not found] ` <mailman.2192.1176873913.7795.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 11+ messages in thread
From: Johan Bockgård @ 2007-04-17 23:47 UTC (permalink / raw)
To: help-gnu-emacs
Dieter Wilhelm <dieter@duenenhof-wilhelm.de> writes:
> \U I didn't see in the elisp manual
For the record, XEmacs does have \U:
`\&' in REPLACEMENT means substitute original matched text.
`\N' means substitute what matched the Nth `\(...\)'.
If Nth parens didn't match, substitute nothing.
`\\' means insert one `\'.
`\u' means upcase the next character.
`\l' means downcase the next character.
`\U' means begin upcasing all following characters.
`\L' means begin downcasing all following characters.
`\E' means terminate the effect of any `\U' or `\L'.
Case changes made with `\u', `\l', `\U', and `\L' override
all other case changes that may be made in the replaced text.
--
Johan Bockgård
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: case change in replacement text with regex-replace
2007-04-17 23:47 ` case change in replacement text with regex-replace Johan Bockgård
@ 2007-04-18 5:19 ` Dieter Wilhelm
[not found] ` <mailman.2192.1176873913.7795.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 11+ messages in thread
From: Dieter Wilhelm @ 2007-04-18 5:19 UTC (permalink / raw)
To: help-gnu-emacs
bojohan+news@dd.chalmers.se (Johan Bockgård) writes:
> Dieter Wilhelm <dieter@duenenhof-wilhelm.de> writes:
>
>> \U I didn't see in the elisp manual
>
> For the record, XEmacs does have \U:
^^^^^^
Thank you, one of the few occasions were I could read that XEmacs has
also it's advantages in comparison to Gnu Emacs.
--
Best wishes
H. Dieter Wilhelm
Darmstadt, Germany
^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <mailman.2192.1176873913.7795.help-gnu-emacs@gnu.org>]
* Re: case change in replacement text with regex-replace
[not found] ` <mailman.2192.1176873913.7795.help-gnu-emacs@gnu.org>
@ 2007-04-18 18:09 ` David Kastrup
2007-04-21 21:19 ` Dieter Wilhelm
0 siblings, 1 reply; 11+ messages in thread
From: David Kastrup @ 2007-04-18 18:09 UTC (permalink / raw)
To: help-gnu-emacs
Dieter Wilhelm <dieter@duenenhof-wilhelm.de> writes:
> bojohan+news@dd.chalmers.se (Johan Bockgård) writes:
>
>> Dieter Wilhelm <dieter@duenenhof-wilhelm.de> writes:
>>
>>> \U I didn't see in the elisp manual
>>
>> For the record, XEmacs does have \U:
> ^^^^^^
>
> Thank you, one of the few occasions were I could read that XEmacs has
> also it's advantages in comparison to Gnu Emacs.
\,(downcase \1)
can be used in Emacs 22 in the replacement text. Sure, it is more
verbose, but also quite more flexible. The Emacs manual has:
For example, to add consecutively numbered strings like `ABC00042' to
columns 73 to 80 (unless they are already occupied), you can use
M-x replace-regexp <RET> ^.\{0,72\}$ <RET>
\,(format "%-72sABC%05d" \& \#) <RET>
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: case change in replacement text with regex-replace
2007-04-18 18:09 ` David Kastrup
@ 2007-04-21 21:19 ` Dieter Wilhelm
0 siblings, 0 replies; 11+ messages in thread
From: Dieter Wilhelm @ 2007-04-21 21:19 UTC (permalink / raw)
To: David Kastrup; +Cc: help-gnu-emacs
David Kastrup <dak@gnu.org> writes:
>>> For the record, XEmacs does have \U:
>> ^^^^^^
>> Thank you, one of the few occasions were I could read that XEmacs has
>> also it's advantages in comparison to Gnu Emacs.
>
> \,(downcase \1)
>
Sure, \, is awesome. but it would be nice if Emacs could also provide
extended REGEXPs like XEmacs.
--
Best wishes
H. Dieter Wilhelm
Darmstadt, Germany
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2007-04-21 21:19 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-11 11:31 case change in replacement text with regex-replace Le TeXnicien de Surface
2007-04-14 20:01 ` Dieter Wilhelm
[not found] ` <mailman.2074.1176581215.7795.help-gnu-emacs@gnu.org>
2007-04-15 8:22 ` Le TeXnicien de Surface
2007-04-15 23:10 ` Dieter Wilhelm
2007-04-15 23:21 ` Dieter Wilhelm
[not found] ` <mailman.2110.1176679588.7795.help-gnu-emacs@gnu.org>
2007-04-16 6:56 ` case change in replacement text with regex-replace [solved] Le TeXnicien de Surface
2007-04-16 19:50 ` Dieter Wilhelm
[not found] ` <mailman.2109.1176678953.7795.help-gnu-emacs@gnu.org>
2007-04-17 23:47 ` case change in replacement text with regex-replace Johan Bockgård
2007-04-18 5:19 ` Dieter Wilhelm
[not found] ` <mailman.2192.1176873913.7795.help-gnu-emacs@gnu.org>
2007-04-18 18:09 ` David Kastrup
2007-04-21 21:19 ` Dieter Wilhelm
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).