* regexp to strip off LaTeX command
@ 2008-12-18 9:08 henry atting
2008-12-18 9:19 ` Andreas Politz
2008-12-22 2:47 ` Plamen Tanovski
0 siblings, 2 replies; 8+ messages in thread
From: henry atting @ 2008-12-18 9:08 UTC (permalink / raw
To: help-gnu-emacs
Hi,
I am searching a regexp for `replace-regexp' to remove only one LaTeX
command. Let's say I want to remove all \textit{} commands but not the
text within the braces, how can I do this?
henry
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: regexp to strip off LaTeX command
2008-12-18 9:08 regexp to strip off LaTeX command henry atting
@ 2008-12-18 9:19 ` Andreas Politz
2008-12-18 9:47 ` henry atting
2008-12-18 13:27 ` Arnaldo Mandel
2008-12-22 2:47 ` Plamen Tanovski
1 sibling, 2 replies; 8+ messages in thread
From: Andreas Politz @ 2008-12-18 9:19 UTC (permalink / raw
To: help-gnu-emacs
henry atting wrote:
> Hi,
>
> I am searching a regexp for `replace-regexp' to remove only one LaTeX
> command. Let's say I want to remove all \textit{} commands but not the
> text within the braces, how can I do this?
>
> henry
>
\\textit{\([^}]*\)} -> \1
If you need to handle escaped brackets the regexp gets a little longer.
-ap
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: regexp to strip off LaTeX command
2008-12-18 9:19 ` Andreas Politz
@ 2008-12-18 9:47 ` henry atting
2008-12-18 15:15 ` Andreas Politz
2008-12-18 13:27 ` Arnaldo Mandel
1 sibling, 1 reply; 8+ messages in thread
From: henry atting @ 2008-12-18 9:47 UTC (permalink / raw
To: help-gnu-emacs
Zitat - Andreas Politz * Do Dez 18 2008 um 10:19 -
> henry atting wrote:
>> Hi,
>>
>> I am searching a regexp for `replace-regexp' to remove only one LaTeX
>> command. Let's say I want to remove all \textit{} commands but not the
>> text within the braces, how can I do this?
>>
>> henry
>>
>
> \\textit{\([^}]*\)} -> \1
>
> If you need to handle escaped brackets the regexp gets a little longer.
>
> -ap
Thanks, works fine. :)
I understand the first part but can you please explain what `\1' stands
for?
henry
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: regexp to strip off LaTeX command
2008-12-18 9:19 ` Andreas Politz
2008-12-18 9:47 ` henry atting
@ 2008-12-18 13:27 ` Arnaldo Mandel
1 sibling, 0 replies; 8+ messages in thread
From: Arnaldo Mandel @ 2008-12-18 13:27 UTC (permalink / raw
To: Andreas Politz; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 701 bytes --]
On Thu, Dec 18, 2008 at 7:19 AM, Andreas Politz <politza@fh-trier.de> wrote:
> henry atting wrote:
>
>> Hi,
>>
>> I am searching a regexp for `replace-regexp' to remove only one LaTeX
>> command. Let's say I want to remove all \textit{} commands but not the
>> text within the braces, how can I do this?
>>
>> henry
>>
>>
> \\textit{\([^}]*\)} -> \1
>
> If you need to handle escaped brackets the regexp gets a little longer.
>
They can get impossibly longer. There is no way to get regexps to do this
job in full.
Your best bet is to use an utility called detex together with
shell-command-on-region.
detex is in the Debian package texlive-extra-utils, but can certainly be
obtained directly.
am
[-- Attachment #2: Type: text/html, Size: 1182 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: regexp to strip off LaTeX command
2008-12-18 9:47 ` henry atting
@ 2008-12-18 15:15 ` Andreas Politz
0 siblings, 0 replies; 8+ messages in thread
From: Andreas Politz @ 2008-12-18 15:15 UTC (permalink / raw
To: help-gnu-emacs
henry atting wrote:
> Zitat - Andreas Politz * Do Dez 18 2008 um 10:19 -
>
>> henry atting wrote:
>>> Hi,
>>>
>>> I am searching a regexp for `replace-regexp' to remove only one LaTeX
>>> command. Let's say I want to remove all \textit{} commands but not the
>>> text within the braces, how can I do this?
>>>
>>> henry
>>>
>> \\textit{\([^}]*\)} -> \1
>>
>> If you need to handle escaped brackets the regexp gets a little longer.
>>
>> -ap
>
> Thanks, works fine. :)
>
> I understand the first part but can you please explain what `\1' stands
> for?
>
> henry
\1 is a backreference and refers to the 1st parenthese group, much like
a variable.
Here is a better explanation, somewhere in the middle.
(info "(elisp)Regexp Backslash")
-ap
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: regexp to strip off LaTeX command
@ 2008-12-19 9:47 Bourgneuf Francois
0 siblings, 0 replies; 8+ messages in thread
From: Bourgneuf Francois @ 2008-12-19 9:47 UTC (permalink / raw
To: henry atting, help-gnu-emacs
> -----Message d'origine-----
> De :
> help-gnu-emacs-bounces+francois.bourgneuf=groupe-mma.fr@gnu.or
> g
> [mailto:help-gnu-emacs-bounces+francois.bourgneuf=groupe-mma.f
> r@gnu.org] De la part de henry atting
> Envoyé : jeudi 18 décembre 2008 10:48
> À : help-gnu-emacs@gnu.org
> Objet : Re: regexp to strip off LaTeX command
>
> Zitat - Andreas Politz * Do Dez 18 2008 um 10:19 -
>
> > henry atting wrote:
> >> Hi,
> >>
> >> I am searching a regexp for `replace-regexp' to remove
> only one LaTeX
> >> command. Let's say I want to remove all \textit{} commands
> but not the
> >> text within the braces, how can I do this?
> >>
> >> henry
> >>
> >
> > \\textit{\([^}]*\)} -> \1
> >
> > If you need to handle escaped brackets the regexp gets a
> little longer.
> >
> > -ap
>
> Thanks, works fine. :)
>
> I understand the first part but can you please explain what
> `\1' stands
> for?
>
> henry
>
\1 stands for "what is found between the first parenthesis \( [^}]* \)"
Example :
\(foo\).*\(bar\) ->\1 \2 would return foo bar (if foo and bar were found in the text, of course).
Bour9
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: regexp to strip off LaTeX command
[not found] <mailman.3104.1229680078.26697.help-gnu-emacs@gnu.org>
@ 2008-12-20 14:11 ` henry atting
0 siblings, 0 replies; 8+ messages in thread
From: henry atting @ 2008-12-20 14:11 UTC (permalink / raw
To: help-gnu-emacs
Zitat - Bourgneuf Francois * Fr Dez 19 2008 um 10:47 -
>> -----Message d'origine-----
>> De :
>> help-gnu-emacs-bounces+francois.bourgneuf=groupe-mma.fr@gnu.or
>> g
>> [mailto:help-gnu-emacs-bounces+francois.bourgneuf=groupe-mma.f
>> r@gnu.org] De la part de henry atting
>> Envoyé : jeudi 18 décembre 2008 10:48
>> À : help-gnu-emacs@gnu.org
>> Objet : Re: regexp to strip off LaTeX command
>>
>> Zitat - Andreas Politz * Do Dez 18 2008 um 10:19 -
>>
>> > henry atting wrote:
>> >> Hi,
>> >>
>> >> I am searching a regexp for `replace-regexp' to remove
>> only one LaTeX
>> >> command. Let's say I want to remove all \textit{} commands
>> but not the
>> >> text within the braces, how can I do this?
>> >>
>> >> henry
>> >>
>> >
>> > \\textit{\([^}]*\)} -> \1
>> >
>> > If you need to handle escaped brackets the regexp gets a
>> little longer.
>> >
>> > -ap
>>
>> Thanks, works fine. :)
>>
>> I understand the first part but can you please explain what
>> `\1' stands
>> for?
>>
>> henry
>>
>
> \1 stands for "what is found between the first parenthesis \( [^}]* \)"
> Example :
> \(foo\).*\(bar\) ->\1 \2 would return foo bar (if foo and bar were
> found in the text, of course).
> Bour9
Copy that ;)
Great thanks to all!
Detex is good for stripping off *all* commands of a region but for
a single command I find `query-replace-regexp' more convenient.
henry
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: regexp to strip off LaTeX command
2008-12-18 9:08 regexp to strip off LaTeX command henry atting
2008-12-18 9:19 ` Andreas Politz
@ 2008-12-22 2:47 ` Plamen Tanovski
1 sibling, 0 replies; 8+ messages in thread
From: Plamen Tanovski @ 2008-12-22 2:47 UTC (permalink / raw
To: help-gnu-emacs
henry atting <nspm_01@literaturlatenight.de> writes:
> I am searching a regexp for `replace-regexp' to remove only one LaTeX
> command. Let's say I want to remove all \textit{} commands but not the
> text within the braces, how can I do this?
This is what I use:
(defun remove-LaTeX-command (befehl)
"removes simple LaTeX command (not starred and without opt. args)
and the surrounding braces"
(interactive "scommand (without the backslash): ")
(save-excursion
(goto-char (point-min))
(while
(re-search-forward (concat "\\\\" befehl "{") nil t)
(replace-match "{")
(save-excursion
(goto-char (TeX-find-balanced-brace))
(delete-char -1))
(delete-char -1))))
best regards
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-12-22 2:47 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-18 9:08 regexp to strip off LaTeX command henry atting
2008-12-18 9:19 ` Andreas Politz
2008-12-18 9:47 ` henry atting
2008-12-18 15:15 ` Andreas Politz
2008-12-18 13:27 ` Arnaldo Mandel
2008-12-22 2:47 ` Plamen Tanovski
-- strict thread matches above, loose matches on Subject: below --
2008-12-19 9:47 Bourgneuf Francois
[not found] <mailman.3104.1229680078.26697.help-gnu-emacs@gnu.org>
2008-12-20 14:11 ` henry atting
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.