Today, I was very happy that I get a solution for my first post here: Find and replace a specific reference pattern by a regular expression.
I'd like to replace following entries (and many more of these types in my document), so that the (number, if present, plus) the first three alpha-letters is written in the bracket after textit. The initial expression has to be appended. Examples:
\nobreakword{(vgl. 1. Johannes 4,16)} => \index[bibel]{@1. Johannes!\textit{1Joh 4,16}}\nobreakword{(vgl. 1. Johannes 4,16)}
\nobreakword{(vgl. Daniel 4,15.17.32f.)} => \index[bibel]{@Daniel!\textit{Dan 4,15.17.32f.}}\nobreakword{(vgl. Daniel 4,15.17.32f.)}
I have also ä/ö/ü characters inside the brackets:
\nobreakword{(vgl. 2. Könige 7,7)} => \index[bibel]{@2. Könige!\textit{2Köng 7,7}}\nobreakword{(vgl. 2. Könige 7,7)}
I'd like to include patterns in which the numerical part is written on the next line (because of copy paste) there is an ENTER (space/many blanck characters) between the text and numbers, e.g.:
\nobreakword{(vgl.
1. Korinther 13,4-7.8-12)} => \index[bibel]{@1. Korinther!\textit{1Kor 13,4-7.8-12}}\nobreakword{(vgl. 1. Korinther 13,4-7.8-12)}
\nobreakword{(vgl. 1.
Korinther 13,4-7.8-12)} => \index[bibel]{@1. Korinther!\textit{1Kor 13,4-7.8-12}}\nobreakword{(vgl. 1. Korinther 13,4-7.8-12)}
\nobreakword{(vgl. 1. Korinther
13,4-7.8-12)} => \index[bibel]{@1. Korinther!\textit{1Kor 13,4-7.8-12}}\nobreakword{(vgl. 1. Korinther 13,4-7.8-12)}
I have other text which should not be changed:
\index[stichwort]{Begriffe!Zeichen} => \index[stichwort]{Begriffe!Zeichen}
\index[stichwort]{Bilder [wörtl./bildhaft:Gleichnis,Symbol/beides]!Personen!Abraham} => \index[stichwort]{Bilder [wörtl./bildhaft:Gleichnis,Symbol/beides]!Personen!Abraham}
If possible I'd like again to use https://regex101.com
I tried (without success): \\nobreakword{(vgl. (\d+)(?:\.\s+))?(.{3})[\s\S]*?([a-z0-9.,-]+)}
Is it possible to use a single search pattern + single replace pattern with regular expression to replace all of the examples in one step?
Aucun commentaire:
Enregistrer un commentaire