[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). 대답은 정규 표현식을 사용하지 않는다는 것입니다. 올바른 도구가 아니기 때문입니다. –