2013-10-04 2 views
0

PHP 업데이트 후 5.4.19에서 이전에 없었던 새로운 경고가 발생했습니다. 그것은 말합니다 : Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in ... on line 645. 당신이 645에 이해할 수 있듯이preg_replace 경고를 수정하는 방법은 무엇입니까?

private function BBtoHTML($input_string) 
{ 
    $search = array(
     '/\[b\](.*?)\[\/b\]/is', 
     '/\[i\](.*?)\[\/i\]/is', 
     '/\[u\](.*?)\[\/u\]/is', 
     '/\[s\](.*?)\[\/s\]/is', 
     '/\[quote\](.*?)\[\/quote\]/is', 
     '/\[code\](.*?)\[\/code\]/is', 
     '/\[url\=(.*?)\](.*?)\[\/url\]/is', 
     '/\[(left|center|right)\](.*?)\[\/(left|center|right)\]/is', 
     '/\[font\=(.*?)\](.*?)\[\/font\]/is', 
     '/\[size\=(.*?)\](.*?)\[\/size\]/is', 
     '/\[color\=(.*?)\](.*?)\[\/color\]/is', 
     '\{PAGEBREAK\}', 
    ); 

    $replace = array(
     '/<strong>$1</strong>/', 
     '/<em>$1</em>/', 
     '/<span style="text-decoration: underline;">$1</span>/', 
     '/<del>$1</del>/', 
     '/<blockquote>$1</blockquote>/', 
     '/<code>$1</code>/', 
     '/<a href="$1" target="_blank">$2</a>/', 
     '/<div style="text-align: $1;">$2</div>/', 
     '/<span style="font-family: $1;">$2</span>/', 
     '/<span style="font-size: $1;">$2</span>/', 
     '/<span style="color: $1;">$2</span>/', 
     '/<!--nextpage-->/' 
    ); 

    return preg_replace($search, $replace, $input_string); 
} 

return preg_replace($search, $replace, $input_string)입니다 :

는 방법이있다.

답변

1

마지막으로 가지고있는 패턴은 '\{PAGEBREAK\}'입니다. 당신은 백 슬래시 문자 그대로 \{PAGEBREAK\} 포함 일치하는 것을 의미하는 경우 패턴이 있어야한다 : 당신이 {PAGEBREAK} 일치하는 것을 의미하는 경우

 '/\\\\{PAGEBREAK\\\\}/', 

패턴이 있어야한다 :

 '/{PAGEBREAK}/', 
관련 문제