2015-01-07 5 views
0

구문 분석을 실행할 때 Oembed 시스템을 통해 링크로 URL을 바꾸기 위해 이미지가 손상됩니다. 이 정규식을 편집하여 BBCode 괄호 안의 링크를 캡처하지 못하도록하려면 어떻게해야합니까?정규식은 URL을 찾지 만 BBCode URL은 찾지 못합니까?

// Parse bbcodes before link parsing for image support 
    $text = self::parseBBCodes($text); 

    $text = preg_replace_callback('/(https?:\/\/.*?)(\s|$)/i', function ($match) use (&$oembedCount, &$maxOembedCount) { 

지금은 작품을 보인다

$text = preg_replace_callback('/(?<!\])(https?:\/\/.*?)(\s|$)(?!\[)/i', function ($match) use (&$oembedCount, &$maxOembedCount) { 

을 시도했지만 이미지가 변환되지 않습니다. 정규 bbcode가 있지만.

BBCode의 기능

/** 
* Parse BBCode 
* 
* @param string $text contains the text with BBCode to be parsed 
*/ 
public static function parseBBcodes($text) 
{ 

    // BBcode array 
    $find = array(
     '~\[b\](.*?)\[/b\]~s', 
     '~\[i\](.*?)\[/i\]~s', 
     '~\[u\](.*?)\[/u\]~s', 
     '~\[quote\](.*?)\[/quote\]~s', 
     '~\[size=(.*?)\](.*?)\[/size\]~s', 
     '~\[color=(.*?)\](.*?)\[/color\]~s', 
     '~\[img\](https?://.*?\.(?:jpg|jpeg|gif|png|bmp))\[/img\]~s' 
    ); 

    // HTML tags to replace BBcode 
    $replace = array(
     '<b>$1</b>', 
     '<i>$1</i>', 
     '<span style="text-decoration:underline;">$1</span>', 
     '<pre>$1</'.'pre>', 
     '<span style="font-size:$1px;">$2</span>', 
     '<span style="color:$1;">$2</span>', 
     '<img src="$1" alt="" />' 
    ); 

    // Replacing the BBcodes with corresponding HTML tags 
    return preg_replace($find,$replace,$text); 
} 

답변

-1
당신이 당신의 텍스트를 제거 할 수 있습니다

$text= strip_tags($text); 
관련 문제