Ich habe etwas Text, der in [quote][/quote]
gewickelt ist und ich versuche, den gesamten Text vor diesen Tags, alles zwischen diesen Tags und alles nach diesen Tags zu vergleichen. Der Haken ist, dass es mehrere Vorkommen von ihnen geben kann, aber nicht ineinander.preg_match_all wird komisch
Der Grund für mich ist, weil ich einen Filter für den gesamten Text außerhalb dieser Tags ausführen möchte, ob mehrere Vorkommen vorhanden sind oder nicht.
Dies ist, was ich beginne, mit zu arbeiten:
preg_match_all("/(^.*)\[quote\](.*?)\[\/quote\](.*)/si", $reply['msg'], $getthequotes);
Hier ist der Ausgang:
Array
(
[0] => Array
(
[0] => putting some stuff before the quote
[quote][b]Logan said[/b][br]testing this youtube link http://www.youtube.com/watch?v=8UVNT4wvIGY&feature=g-music&context=G2db8219YMAAAAAAAAAA[br][br]did it work?[br][br][i]04/04/12 23:48:46: Edited by Logan(2)[/i][br][br][i]04/04/12 23:55:44: Edited by Logan(2)[/i][/quote]
yep
http://www.youtube.com/watch?v=8UVNT4wvIGY&feature=g-music&context=G2db8219YMAAAAAAAAAA
adding a quote
[quote][b]Logan said[/b][br]This is the start of the second quote http://www.youtube.com/watch?v=8UVNT4wvIGY&feature=g-music&context=G2db8219YMAAAAAAAAAA[br][br]did it work?[br][br][i]04/04/12 23:48:46: Edited by Logan(2)[/i][br][br][i]04/04/12 23:55:44: Edited by Logan(2)[/i][/quote]
[i]04/07/12 20:18:07: Edited by Logan(2)[/i]
)
[1] => Array
(
[0] => putting some stuff before the quote
[quote][b]Logan said[/b][br]testing this youtube link http://www.youtube.com/watch?v=8UVNT4wvIGY&feature=g-music&context=G2db8219YMAAAAAAAAAA[br][br]did it work?[br][br][i]04/04/12 23:48:46: Edited by Logan(2)[/i][br][br][i]04/04/12 23:55:44: Edited by Logan(2)[/i][/quote]
yep
http://www.youtube.com/watch?v=8UVNT4wvIGY&feature=g-music&context=G2db8219YMAAAAAAAAAA
adding a quote
)
[2] => Array
(
[0] => [b]Logan said[/b][br]This is the start of the second quote http://www.youtube.com/watch?v=8UVNT4wvIGY&feature=g-music&context=G2db8219YMAAAAAAAAAA[br][br]did it work?[br][br][i]04/04/12 23:48:46: Edited by Logan(2)[/i][br][br][i]04/04/12 23:55:44: Edited by Logan(2)[/i]
)
[3] => Array
(
[0] =>
[i]04/07/12 20:18:07: Edited by Logan(2)[/i]
)
)
Wie Sie es nicht immer die gewünschte Ausgabe sehen. Jede Hilfe wäre willkommen.
Ahh ... eine Markup-Sprache, die nicht HTML ist - sicherlich Regexes endlich das richtige Werkzeug sein? –
Ich habe benutzerdefinierte BBCode wie Tags, die in HTML geparst werden. Das Regex-Parsing erfolgt in PHP. –
Es tut mir leid, ich war ein bisschen sarkastisch, angesichts dieses [extrem weit verbreiteten Irrtums] (http://stackoverflow.com/a/1732454/596781). Die Antwort ist, * benutze keine Regexes dafür, da sie nicht das richtige Werkzeug sind. –