[oXygen-user] Search and Replace with regular expression
Gerrit Imsieke
gerrit.imsieke at le-tex.de
Thu Oct 5 06:11:24 CDT 2017
In order to avoid searching across multiple terms/lines, you can also exclude the closing brace from the regex groups (probably escaped): ([^\}>]+?)
If the TeX code within the terms contains curly braces, it’s probably time to use a real parser instead of regexes, maybe as part of a conversion tool such as latexml (http://dlmf.nist.gov/LaTeXML/) plus custom XSLT.
On October 5, 2017 12:57:46 PM GMT+02:00, Gerrit Imsieke <gerrit.imsieke at le-tex.de> wrote:
>I’m currently on the mobile and can’t try it out in oXygen.
>
>But I think you can either untick “dot matches anything” in the
>search/replace dialog or you can write (>([^>]+?))? instead of
>(>(.+?))?
>
>For tertiary, you can add another (>([^>]+?))? group and replace it
>with <tertiary>$5</tertiary>, followed by deleting empty secondary and
>tertiary elements.
>
>
>On October 5, 2017 12:28:39 PM GMT+02:00, Bernhard Kleine
><bernhard.kleine at gmx.net> wrote:
>>Hi Gerrit
>>
>>I tried it an it starts to search over newline. Since the book was
>>heavily indexed this renders the proposed search non valid. Before I
>>could something like
>>\index{IGF-Rezeptor}\index{GH-Rezeptor}\index{IGFBP} usefull by adding
>>line feeds. But with your construct that is not possible.
>>
>>BTW the problem has another level of complexity. As you are aware
>>docbook and latex have three levels of indexing.
>>
>>the full expression to be replaced would be
>>
>>\index{Nerven>splanchnische>CCK}. I hope that you could propose a
>>solution to that, too.
>>
>>Kind regards and greetings from the Black Forest
>>
>>Bernhard
>>
>>
>>Am 05.10.2017 um 11:50 schrieb Imsieke, Gerrit, le-tex:
>>> You can replace \\index\{([^>]+)(>(.+?))?\} with
>>>
><indexterm><primary>$1</primary><secondary>$3</secondary></indexterm>
>>> (using regex search again, of course) and afterwards remove empty
>>> <secondary></secondary> elements.
>>>
>>> On 05.10.2017 11:28, Bernhard Kleine wrote:
>>>> Many thanks for this, Franz-Josef.
>>>>
>>>> since you are seemingly an expert I would also like to know
>>>>
>>>> how \index{Nerven>splanchnische} will become
>>>>
>>>>
>><indexterm><primary>Nerven</primary><secondary>splanchnische</secondary></indexterm>,
>>>>
>>>>
>>>> a two parameter search
>>>>
>>>> Merci vielmals in advance
>>>>
>>>> Bernhard
>>>>
>>>>
>>>> Am 05.10.2017 um 09:05 schrieb Franz-Josef Knelangen:
>>>>> Hello Bernhard,
>>>>>
>>>>> that works w/o problems, if you mask the brackets during search
>and
>>>>> group the string you need in the replace, like:
>>>>>
>>>>> Find:\\citep\{(.*)\}
>>>>> Replace<citation><biblioref linkend="$1"/></citation>
>>>>>
>>>>> Greetings,
>>>>> Franz-Josef
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Am 5. Oktober 2017 um 06:39:14, Bernhard Kleine
>>>>> (bernhard.kleine at gmx.net <mailto:bernhard.kleine at gmx.net>)
>schrieb:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> while porting from LaTeX to docbook5 I encounter numerous cases
>>>>>> where a
>>>>>> regular expression search and replace would be extremely
>helpfull.
>>>>>> E.g.
>>>>>> I have a citation as \citep{ABC65}. This should become
>>>>>> <citation><biblioref linkend="ABC65"/></citation>.
>>>>>>
>>>>>> Is that possible in oxygen and how to achieve it?
>>>>>>
>>>>>> Regards
>>>>>>
>>>>>> Bernhard Kleine
>>>>>>
>>>>>> --
>>>>>> spitzhalde9
>>>>>> D-79853 lenzkirch
>>>>>> bernhard.kleine at gmx.net
>>>>>> www.b-kleine.com, www.urseetal.net
>>>>>> -
>>>>>> thunderbird mit enigmail
>>>>>> GPG schlüssel: D5257409
>>>>>> fingerprint:
>>>>>> 08 B7 F8 70 22 7A FC C1 15 49 CA A6 C7 6F A0 2E D5 25 74 09
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> oXygen-user mailing list
>>>>>> oXygen-user at oxygenxml.com
>>>>>> https://www.oxygenxml.com/mailman/listinfo/oxygen-user
>>>>>
>>>>>
>>>>>
>>------------------------------------------------------------------------
>>>>>
>>>>>
>>>>> *AKG Software Consulting GmbH
>>>>> Franz-Josef Knelangen*
>>>>>
>>>>>
>>>>> Uhlandstraße 12
>>>>> 79423 Heitersheim
>>>>> Germany
>>>>>
>>>>> Tel.: +49 (0)7634 5612-611
>>>>> Fax: +49 (0)7634 5612-300
>>>>> E-Mail: _fjk at akgsoftware.de_
>>>>> Internet: www.akgsoftware.de <http://www.akgsoftware.de>
>>>>>
>>>>> Geschäftsführer: Dipl.-Ing. Artur K. Günther, Dipl.-Ing. Arno
>>>>> Brüggemann, Dipl.-Ing. (FH) Bernhard Feser, Dipl.-Ing. Jens
>Günther
>>>>> Sitz der Gesellschaft: Heitersheim, HRB 310383 (Amtsgericht
>>Freiburg)
>>>>>
>>>>
>>>> --
>>>> spitzhalde9
>>>> D-79853 lenzkirch
>>>> bernhard.kleine at gmx.net
>>>> www.b-kleine.com,www.urseetal.net
>>>> -
>>>> thunderbird mit enigmail
>>>> GPG schlüssel: D5257409
>>>> fingerprint:
>>>> 08 B7 F8 70 22 7A FC C1 15 49 CA A6 C7 6F A0 2E D5 25 74 09
>>>>
>>>>
>>>> _______________________________________________
>>>> oXygen-user mailing list
>>>> oXygen-user at oxygenxml.com
>>>> https://www.oxygenxml.com/mailman/listinfo/oxygen-user
>>>>
>>>
>>
>>--
>>spitzhalde9
>>D-79853 lenzkirch
>>bernhard.kleine at gmx.net
>>www.b-kleine.com, www.urseetal.net
>>-
>>thunderbird mit enigmail
>>GPG schlüssel: D5257409
>>fingerprint:
>>08 B7 F8 70 22 7A FC C1 15 49 CA A6 C7 6F A0 2E D5 25 74 09
>
>--
>Sent from my Android device with K-9 Mail. Please excuse my brevity.
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.oxygenxml.com/pipermail/oxygen-user/attachments/20171005/9ae2bc84/attachment.html>
More information about the oXygen-user
mailing list