|
|
Up |
|
|
  |
Author: Tassilo HornTassilo Horn Date: Aug 15, 2008 00:54
"xiaopeng hu" gmail.com> writes:
Hi!
> Then how to replace all my $$ ... $$ to \[ \] through search and
> replace? Thanks
M-x query-replace-regexp RET \$\$\(.+\)\$\$ RET \\[\1\\] RET
Bye,
Tassilo
--
Richard Stallman has no problem using emacs. He wrote it with his 4
hands.
|
| |
|
| | 10 Comments |
|
  |
Author: Ralf AngeliRalf Angeli Date: Aug 15, 2008 01:40
* Tassilo Horn (2008-08-15) writes:
> "xiaopeng hu" gmail.com> writes:
>
>> Then how to replace all my $$ ... $$ to \[ \] through search and
>> replace? Thanks
>
> M-x query-replace-regexp RET \$\$\(.+\)\$\$ RET \\[\1\\] RET
This won't work because `.' does not match a newline. Using `[^$]'
instead should do it.
--
Ralf
|
| |
|
| | no comments |
|
  |
Author: Tassilo HornTassilo Horn Date: Aug 15, 2008 02:05
Ralf Angeli caeruleus.net> writes:
Hi Ralf,
>> M-x query-replace-regexp RET \$\$\(.+\)\$\$ RET \\[\1\\] RET
>
> This won't work because `.' does not match a newline.
Ok, but at least it works for oneliners.
> Using `[^$]' instead should do it.
Right, that's better.
Bye,
Tassilo
--
[Emacs] is written in Lisp, which is the only computer language that is
beautiful. -- Neal Stephenson, _In the Beginning was the Command Line_
|
| |
| no comments |
|
  |
Author: Thierry VolpiattoThierry Volpiatto Date: Aug 15, 2008 02:08
Ralf Angeli caeruleus.net> writes:
> * Tassilo Horn (2008-08-15) writes:
>
>> "xiaopeng hu" gmail.com> writes:
>>
>>> Then how to replace all my $$ ... $$ to \[ \] through search and
>>> replace? Thanks
>>
>> M-x query-replace-regexp RET \$\$\(.+\)\$\$ RET \\[\1\\] RET
>
> This won't work because `.' does not match a newline. Using `[^$]'
> instead should do it.
Just a note about re-builder and regex-tool:
To build a regex to use in a program or with query-replace-regexp, you
can use one of these tools, however, re-builder will build a regex to
use in a program and this regex will not work in query-replace-regexp.
Regex-tool will build a regex more usable with query-replace-regexp.
[0-9]\\{2\\} ==> work in a program but not in query-replace
[0-9]\{2\} ==> work in query-replace but not in a program
|
| Show full article (0.91Kb) |
| no comments |
|
  |
Author: Phil CarmodyPhil Carmody Date: Aug 15, 2008 02:34
Tassilo Horn member.fsf.org> writes:
> Ralf Angeli caeruleus.net> writes:
>
> Hi Ralf,
>
>>> M-x query-replace-regexp RET \$\$\(.+\)\$\$ RET \\[\1\\] RET
>>
>> This won't work because `.' does not match a newline.
>
> Ok, but at least it works for oneliners.
>
>> Using `[^$]' instead should do it.
>
> Right, that's better.
$$ What about this $1,000,000 example? $$
Such strings may not be possible in the original data set,
of course, so it might not be an issue.
|
| Show full article (0.77Kb) |
| no comments |
|
  |
Author: Ralf AngeliRalf Angeli Date: Aug 15, 2008 03:13
* Phil Carmody (2008-08-15) writes:
> Tassilo Horn member.fsf.org> writes:
>> Ralf Angeli caeruleus.net> writes:
>>
>>>> M-x query-replace-regexp RET \$\$\(.+\)\$\$ RET \\[\1\\] RET
>>>
>>> This won't work because `.' does not match a newline.
>>
>> Ok, but at least it works for oneliners.
>>
>>> Using `[^$]' instead should do it.
>>
>> Right, that's better.
>
> $$ What about this $1,000,000 example? $$
Then you could use something like
C-M-%% \$\$ \,(if (zerop (mod \# 2)) "\\[" "\\]")
--
Ralf
|
| |
| no comments |
|
  |
Date: Aug 15, 2008 10:24
On Fri, Aug 15 2008, Ralf Angeli wrote:
> * Phil Carmody (2008-08-15) writes:
>> $$ What about this $1,000,000 example? $$
> C-M-%% \$\$ \,(if (zerop (mod \# 2)) "\\[" "\\]")
(replace-string "$$" '("\\\[" "\\\]"))
Bye, Reiner.
|
| |
| no comments |
|
  |
Author: Nikos ApostolakisNikos Apostolakis Date: Aug 15, 2008 18:18
Reiner Steib writes:
> On Fri, Aug 15 2008, Ralf Angeli wrote:
>
>> * Phil Carmody (2008-08-15) writes:
>>> $$ What about this $1,000,000 example? $$
>> C-M-%% \$\$ \,(if (zerop (mod \# 2)) "\\[" "\\]")
>
> (replace-string "$$" '("\\\[" "\\\]"))
>
This is great!
Is this an undocumented feature of replace-string? I can't find it in
the help string or the info manual.
Nikos
|
| |
| no comments |
|
  |
Date: Aug 16, 2008 02:21
On Sat, Aug 16 2008, Nikos Apostolakis wrote:
> Reiner Steib writes:
>> (replace-string "$$" '("\\\[" "\\\]"))
>
> This is great!
David Kastrup once mention this (or a similar example with
`replace-regexp') on some newsgroup or mailing list. I don't remember
if it is possible to use this with M-x replace-... or
query-replace... as well.
> Is this an undocumented feature of replace-string? I can't find it in
> the help string or the info manual.
I can't find it in the docs neither. Please suggest to document it
(via M-x report-emacs-bug RET).
Bye, Reiner.
|
| |
| no comments |
|
  |
|
|
  |
Author: harvenharven Date: Aug 16, 2008 06:49
> David Kastrup once mention this (or a similar example with
> `replace-regexp') on some newsgroup or mailing list. I don't remember
> if it is possible to use this with M-x replace-... or
> query-replace... as well.
M-:(replace-regexp "\\$\\$" '("\\\[" "\\\]"))
It is in fact a feature of the perform-replace function.
Quoting the elisp manual section dealing with this function:
> The argument REPLACEMENTS specifies what to replace occurrences > with. If it is a string, that string is used. It can also be a
> list of strings, to be used in cyclic order.
> If REPLACEMENTS is a cons cell, `(FUNCTION . DATA)', this means to
> call FUNCTION after each match to get the replacement text. This
> function is called with two arguments: DATA, and the number of
> replacements already made.
|
| |
| no comments |
|
RELATED THREADS |
  |
|
|
|
|
|