[linux-l] regex
Olaf Radicke
briefkasten at olaf-radicke.de
Mo Jan 9 00:28:40 CET 2012
Lutz Willek <lutz.willek at belug.de> hat am 8. Januar 2012 um 23:51
geschrieben:
> Hi,
>
> Gegeben sei folgender String:
> bla \\section{a} \section{b} foo \\section{c} bar \section{d}
>
> Also wenn ich Dir richtig verstanden habe, aus diesen String willst Du
> im Ergebnis folgendes haben: (????)
> bla \\section{a} {b} foo \\section{c} bar {d}
>
> Dann liegt das erste Problem schon mal bei echo.
> Du machst folgendes:
> echo "bla \\section{a} \section{b} foo \\section{c} bar \section{d}"
> bla \section{a} \section{b} foo \section{c} bar \section{d}
>
> Du meinst aber:
> echo 'bla \\section{a} \section{b} foo \\section{c} bar \section{d}'
> bla \\section{a} \section{b} foo \\section{c} bar \section{d}
>
> hier maskiert sich das \\ schon zum \...
Ah, das habe ich nicht geprüft!
Okay, trotzdem bekomme ich nicht das was ich erwarte:
or at gkiste:~$ echo 'bla \\section{a} \section{b} foo \\section{c} bar
\section{d}' | sed 's/ \\section/ /g' bla \\section{a} {b} foo \\section{c}
bar {d}
Nach meinem Verständnis müsste hier das herauskommen:
\{a} {b} foo \{c} bar {d}
or at gkiste:~$ echo 'bla \\section{a} \section{b} foo \\section{c} bar
\section{d}' | sed 's/ \\{1}section/ /g'
bla \\section{a} \section{b} foo \\section{c} bar \section{d}
Und hier müsse herrauskommen:
bla \\section{a} {b} foo \\section{c} bar {d}
Was ich will ist:
bla \\section{a} {b} foo \\section{c} bar {d}
Das bekomme ich auch mit Variante A, aber ich verstehe nicht warum.
Gruß
Olaf
Mehr Informationen über die Mailingliste linux-l