need some help with regular expressions
-
I need some help with regular expressions for the sake of editing a Wikipedia article.
I need to replace each instance of
<ref>AS, Rn. *, S. *.</ref>
with
{{sfn|Wirtz|2017|loc=Rn. *|S=*}}
where * represent numbers
but hereby not ruin any different <ref></ref>s.
-
@eugene-fishgalov said in need some help with regular expressions:
I need some help with regular expressions for the sake of editing a Wikipedia article.
Can you provide several examples before the changes and what they should look like after the changes are made. At the moment I’m having diffuclty in understanding exactly what you need.
Terry
-
@terry-r Yes. For instance,
<ref>AS, Rn. 130 S. 62</ref>
should be
{{sfn|Wirtz|2017|loc=Rn. 130|S=62}
And
<ref>AS, S. 106, Rn. 195-196.</ref>
should be
{{sfn|Wirtz|2017|loc=Rn. 195-196|S=106}
You are welcome to look into the actual wiki-code: https://ru.wikipedia.org/w/index.php?title=Участник:Eugrus/Неосновательное_обогащение_в_праве_Германии&action=edit
-
Hello @eugene-fishgalov, @terry-r and All
Thanks for your two examples, but I still couldn’t imagine the general goal :-(. Here is how I proceeded to get a better idea of the problem :
-
Firstly, I copied all your
Wikipedia
article in a new tab. -
Secondly, I marked all the ranges
<ref>•••••••</ref>
with the regex<ref>.*?</ref>
in red (Ctrl + M
) -
I then clicked on the
Copy Marked Text
button -
After pasting, I sorted all these lines (
Edit > Lines Operations > Sort Lines Lexicographically Ascending
) -
I re-organized some adjacent ranges
<ref>•••••••</ref>
one per line -
Finally I tried to manually sort this list by similarity and I got :
<ref>AS, Rn. 120, S. 57.</ref> <ref>AS, Rn. 127 S. 60</ref> <ref>AS, Rn. 127 S. 60</ref> <ref>AS, Rn. 129 S. 61</ref> <ref>AS, Rn. 130 S. 62</ref> <ref>AS, Rn. 131 S. 62</ref> <ref>AS, Rn. 131 S. 62</ref> <ref>AS, Rn. 132 S. 62<</ref> <ref>AS, Rn. 134 S. 63</ref> <ref>AS, Rn. 142, S. 71.</ref> <ref>AS, Rn. 151, S. 77.</ref> <ref>AS, S. 101, Rn. 186.</ref> <ref>AS, S. 102, Rn. 189.</ref> <ref>AS, S. 102, Rn. 190.</ref> <ref>AS, S. 105, Rn. 194.</ref> <ref>AS, S. 106, Rn. 195-196.</ref> <ref>AS, S. 82, Rn. 159, Fn. 238.</ref> <ref>AS, S. 82, Rn. 159.</ref> <ref>AS, S. 83, Rn. 161.</ref> <ref>AS, S. 84, Rn. 161.</ref> <ref>AS, S. 87, Rn. 164; S. 99; Rn. 184.</ref> <ref>AS, S. 93, Rn. 174.</ref> <ref>AS, S. 93-94, Rn. 175.</ref> <ref>AS, S. 97, Rn. 180.</ref> <ref>AS, S. 98, Rn. 181.</ref> <ref>AS, S. 98, Rn. 182.</ref> <ref>BGHZ 40, 272; 50, 227; 56, 228; 72, 246.</ref> <ref>BGHZ 58, 188</ref> <ref>Baur/Stürner, Sachenrecht, 18. Aufl. 2009, § 37 Rn. 48; Vieweg/Werner, Sachenrecht; 7. Aufl. 2015, § 15 Rn. 27</ref> <ref>Büdenbender, Grundsätze des Hypothekenrechts, JuS 1996, 665.</ref> <ref>MüKoBGB/Lieder, 7. Aufl. 2017, § 1113 Rn. 83; Baur/Stürner, Sachenrecht, 18. Aufl. 2009, § 37 Rn. 48; Rimmelspacher, Kreditsicherungsrecht, 2. Aufl. 1987, § 10 Rn. 711 ff.</ref> <ref>Rimmelspacher, Kreditsicherungsrecht, 2. Aufl. 1987, Rn. 714; Vieweg/Werner, Sachenrecht, 7. Aufl. 2015, § 15 Rn. 27.</ref> <ref>Rimmelspacher, Kreditsicherungsrecht, 2. Aufl. 1987, Rn. 714; Vieweg/Werner, Sachenrecht, 7. Aufl. 2015, § 15 Rn. 27.</ref> <ref>Vieweg/Werner, Sachenrecht, 7. Aufl. 2015, § 15 Rn. 27</ref> <ref>[[:Файл:RGZ 150, 1.pdf|RGZ 150, 1]]; BGH [https://dejure.org/1982,163 NJW 1983, 1420].</ref> <ref>[[:Файл:RGZ 161, 52.pdf|RGZ 161, 52]]; [https://dejure.org/1958,549 BGHZ 28, 164]; [https://dejure.org/2015,13297 BGHZ 206, 69].</ref> <ref>[https://dejure.org/1959,456 BGHZ 29, 157]</ref> <ref>[https://dejure.org/1963,7 BGHZ 40, 272]</ref> <ref>[https://dejure.org/1970,170 BGHZ 53, 144]; [https://dejure.org/1971,21 57, 137]</ref> <ref>[https://dejure.org/1971,21 BGHZ 57, 137]</ref> <ref>[https://dejure.org/1973,48 BGHZ 61, 289]</ref> <ref>[https://dejure.org/1976,124 BGHZ 66, 362]; [https://dejure.org/1976,156 66, 372]; [https://dejure.org/1976,288 67, 75]; [https://dejure.org/1983,140 87, 393, 396]; [https://dejure.org/1983,362 88, 232, 235]</ref> <ref>[https://dejure.org/1978,150 BGHZ 72, 9, 12]</ref> <ref>[https://dejure.org/1980,384 BGHZ 78, 216]</ref> <ref>[https://dejure.org/1983,362 BGHZ 88, 232, 236]</ref> <ref>[https://dejure.org/1984,281 BGHZ 89, 376]; [https://dejure.org/1984,915 BGH NJW 1984, 2205]</ref> <ref>[https://dejure.org/1994,893 BGHZ 126, 105]</ref> <ref>[https://dejure.org/2001,9 BGH NJW 2001, 1127]</ref> <ref>[https://dejure.org/2002,1296 BGH NJW 2002, 3772]; [https://dejure.org/2003,62 BGHZ 155, 380]; MüKoBGB, § 814, Rn. 12.</ref> <ref>[https://dejure.org/2008,1843 BGH, 13.02.2008 - VIII ZR 208/07, NJW 2008, 1878].</ref> <ref>[https://dejure.org/2015,20967 BGHZ 205, 377]</ref> <ref>[https://dejure.org/2015,4962 BGH, 04.03.2015 - XII ZR 46/13, NJW 2015, 1523.]</ref> <ref>https://lorenz.userweb.mwn.de/urteile/vizr36_00.htm</ref> <ref>В данном случае речь идёт не (обязательно) о договоре поручения, а о «указании» в описанном выше кондикционно-правовом смысле. Немецкие термины Anweisender, Angewiesener и Zuwendungsempfänger используются только в рамках этого специфического института, тогда как доверитель и поверенный в собственно-юридическом смысле называются Auftraggeber и Auftragnehmer.</ref> <ref>В дореволюционном переводе: https://viewer.rusneb.ru/ru/rsl01003642821?page=193 — «удовлетворение»</ref> <ref>В нем. юриспруденции согласно так называемому «горизонту получателя», нем. Empfängerhorizont.</ref> <ref>За применение кондикции: [https://dejure.org/1973,841 BGH NJW 1973, 612]; за правило о нарушении основания сделок как специальный закон: [https://dejure.org/1992,508 BGH NJW 1992, 2690].</ref> <ref>Основанные на: Westermann, Sachenrecht, 5. Aufl. § 128 III 1; Baur, Sachenrecht, 4. Aufl, § 55 B II 2 a</ref> <ref>Со ссылкой на Kregel in RGRK 11. Aufl. Anm. 8; Staudinger/Spreng, 11. Aufl. Rdz. 10; Palandt/Degenhart, 27. Aufl. Anm. 3 a und Erman/Rinke, 2. Aufl. Anm. 3, к § 1204 ГГУ.</ref>
I, then, understood that we should stay concentrated on the
<ref>AS, •••••••</ref>
ranges, only ! so, after a manual sorting, I got the shorter list, below :<ref>AS, Rn. 127 S. 60</ref> <ref>AS, Rn. 127 S. 60</ref> <ref>AS, Rn. 129 S. 61</ref> <ref>AS, Rn. 130 S. 62</ref> <ref>AS, Rn. 131 S. 62</ref> <ref>AS, Rn. 131 S. 62</ref> <ref>AS, Rn. 132 S. 62<</ref> <ref>AS, Rn. 134 S. 63</ref> <ref>AS, Rn. 120, S. 57.</ref> <ref>AS, Rn. 142, S. 71.</ref> <ref>AS, Rn. 151, S. 77.</ref> <ref>AS, S. 82, Rn. 159.</ref> <ref>AS, S. 83, Rn. 161.</ref> <ref>AS, S. 84, Rn. 161.</ref> <ref>AS, S. 93, Rn. 174.</ref> <ref>AS, S. 97, Rn. 180.</ref> <ref>AS, S. 98, Rn. 181.</ref> <ref>AS, S. 98, Rn. 182.</ref> <ref>AS, S. 101, Rn. 186.</ref> <ref>AS, S. 102, Rn. 189.</ref> <ref>AS, S. 102, Rn. 190.</ref> <ref>AS, S. 105, Rn. 194.</ref> <ref>AS, S. 106, Rn. 195-196.</ref> <ref>AS, S. 93-94, Rn. 175.</ref> <ref>AS, S. 82, Rn. 159, Fn. 238.</ref> <ref>AS, S. 87, Rn. 164; S. 99; Rn. 184.</ref>
Note that one line contains a wrong ending tag
<</ref>
. You can easily modify these lines with the regex S/R :SEARCH
(<+)|>+
REPLACE
?1<:>
Now, I succeeded to find out a correct regex S/R for almost all the above lines. However, could you tell me how to change the two lines , below :
<ref>AS, S. 82, Rn. 159, Fn. 238.</ref> <ref>AS, S. 87, Rn. 164; S. 99; Rn. 184.</ref>
For all the other cases, my regex S/R do give the expected result ;-))
See you later,
Best regards,
guy038
-