[quote][/quote]
で囲まれたテキストがあります。これらのタグの前にあるすべてのテキスト、これらのタグの間のすべて、およびこれらのタグの後ろのすべてを照合しようとしています。キャッチとは、それらが複数存在する可能性があるが、互いに存在しないことである。preg_match_all奇妙なこと
私がこれを行うのは、複数の出現の有無にかかわらず、それらのタグの外のすべてのテキストに対してフィルタを実行したいからです。
これは、私が一緒に仕事し始めているものです:
preg_match_all("/(^.*)\[quote\](.*?)\[\/quote\](.*)/si", $reply['msg'], $getthequotes);
ここでは出力です:
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]
)
)
あなたはそれが所望の出力を得ていない見ることができるように。どんな助けもありがとう。
ああ... HTMLではないマークアップ言語 - 確かに最終的には正しいツールとなるでしょう正規表現しますか? –
私はhtmlに解析されるタグのようなカスタムbbcodeを持っています。すべての正規表現解析はPHPで行われます。 –
申し訳ありませんが、私はこの[非常に一般的な誤り](http://stackoverflow.com/a/1732454/596781)に照らしてちょっと皮肉っていました。答えは正しいツールではないので、正規表現を使ってはいけません。 –