Php 正则表达式查找URL但不查找BBCode URL?

Php 正则表达式查找URL但不查找BBCode URL?,php,regex,bbcode,Php,Regex,Bbcode,当我运行解析时,它会断开图像,通过Oembed系统将URL替换为链接。如何编辑此正则表达式,使其不会捕获BBCode括号内的链接 // Parse bbcodes before link parsing for image support $text = self::parseBBCodes($text); $text = preg_replace_callback('/(https?:\/\/.*?)(\s|$)/i', function ($match) use (

当我运行解析时,它会断开图像,通过Oembed系统将URL替换为链接。如何编辑此正则表达式,使其不会捕获BBCode括号内的链接

    // 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) {
$text=preg\u replace\u回调('/(?$1'),
'$1',
'$1',
'$1',
'$2',
'$2',
''
);
//用相应的HTML标记替换BBCODE
返回preg_replace($find,$replace,$text);
}

您可能需要删除文本

/**
 * 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);
}
$text= strip_tags($text);