Splitting with optionally second line
-
Hi, I want to split the text above in three results. Every result starts with the word "Leistung" and can optionally have a second line starting with "Zusatz". My regex-expression ist currently this:
/Leistung [ ]*[\w\d äöüÄÖÜ]*\n[\w\d äöüÄÖÜ\*]*/gm
But this does not fit exactly. This ist the text:
Leistung Armeotraining ET Anzahl 1
Zusatz *TextZusatz_Anf1*
Leistung Atemtherapie 30 Anzahl 2
Leistung Aktivierungsgruppe Anzahl 3
Zusatz *TextZusatz_Anf3*The result should be:
Leistung Armeotraining ET Anzahl 1
Zusatz *TextZusatz_Anf1*Leistung Atemtherapie 30 Anzahl 2
Leistung Aktivierungsgruppe Anzahl 3
Zusatz *TextZusatz_Anf3*Can anyone help me with the regex-expression? Thank you in advance! Tobias
-
Hi, I want to split the text above in three results. Every result starts with the word "Leistung" and can optionally have a second line starting with "Zusatz". My regex-expression ist currently this:
/Leistung [ ]*[\w\d äöüÄÖÜ]*\n[\w\d äöüÄÖÜ\*]*/gm
But this does not fit exactly. This ist the text:
Leistung Armeotraining ET Anzahl 1
Zusatz *TextZusatz_Anf1*
Leistung Atemtherapie 30 Anzahl 2
Leistung Aktivierungsgruppe Anzahl 3
Zusatz *TextZusatz_Anf3*The result should be:
Leistung Armeotraining ET Anzahl 1
Zusatz *TextZusatz_Anf1*Leistung Atemtherapie 30 Anzahl 2
Leistung Aktivierungsgruppe Anzahl 3
Zusatz *TextZusatz_Anf3*Can anyone help me with the regex-expression? Thank you in advance! Tobias
It will depend on the "flavour" of regex you're using, but something like this seems to work for me:
^Leistung.*$(\n^Zusatz.*$)?
Demo[^] Make sure your regex has the "global" and "multi-line" options set, so that
$
matches the end of a line rather than the end of the input string.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
It will depend on the "flavour" of regex you're using, but something like this seems to work for me:
^Leistung.*$(\n^Zusatz.*$)?
Demo[^] Make sure your regex has the "global" and "multi-line" options set, so that
$
matches the end of a line rather than the end of the input string.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer