2012-07-25 4 views
0

안녕하세요 저는 무한 루프가 발생하기 때문에 제거하려는 콜백 태그가 들어있는이 렉스 파서 템플릿을 가지고 있습니다.문자열에서 lex 태그 블록을 제거하십시오.

PHP로 시도한 preg_replace하지만 흰색 화면이 나타납니다. 내가 제거하려는 태그는이 형식으로되어 있습니다 :

{{ search:query term="value" .. more attributes .. }} 

    // any content between these tags needs to be removed as well, including new lines 

{{ /search:query }} 

을 그리고 이것은 preg_replace이다에서 내 시도입니다 :

$text = preg_replace('@\{\{\ssearch:(.*?)\}\}(.*?)\{\{\s/search:(.*?)\s\}\}@is','',$text); 

그러나이 작동하지 않습니다. 왜 그런 충고가 있니?

답변

0
$text = preg_replace('\{\{\s+search:query(\s+\S+=".*")+\s*\}\}.*\{\{\s*/search:query\s*\}\}Uims', '', $text); 

하나 이상의 attr="value"쌍 다중 선 누락 복수 공백 처리 및 비 탐욕이다.

관련 문제