hi,
Beispiel: Um alles innerhalb von Quotes zu replacen, würde ich z.B. preg_replace('/"[^"]*"/', '""', $foo) benutzen. Die Frage ist nun, wie das umgekehrt gehen würde, d.h. alles AUSSERhalb von Quotes zu entfernen.
Also vor einem " alles matchen, was selber kein " ist, dazwischen etwas, was kein " ist, dann noch mal ein schliessendes ", und alles nachfolgende, was kein " ist? Und dann vielleicht nur den Mittelteil übrig lassen?
Sowas wie
$text = 'Er sagte, "Hallo", und sie erwiderte, "Na, was gibt\'s?" - es war eine sehr interessante Konversation ...';
echo preg_replace('/[^"]*("[^"]*")[^"]*/u', '$1', $text);
Ausgabe:
"Hallo""Na, was gibt's?"
gruß,
wahsaga
--
/voodoo.css:
#GeorgeWBush { position:absolute; bottom:-6ft; }
/voodoo.css:
#GeorgeWBush { position:absolute; bottom:-6ft; }