在 PHP 中自动链接周围没有引号的 url(需要修改代码)


Auto link urls in PHP that don't have quotes around them (Code modify needed)

好的,我一直在使用以下代码来查找我输入的文本中的任何URL,但是有些东西,如YouTube代码或其他东西,其中有链接,它也可以找到这些。 我想修改此代码,以便它忽略已经是某物一部分的链接周围的引号。

'公共函数 auto_link_text($text) {

    $pattern  = '#'b((['w-]+://?|www[.])[^'s()<>]+(?:'(['w'd]+')|([^[:punct:]'s]|/)))#';
    return preg_replace_callback($pattern, array($this, 'auto_link_text_callback'), $text);
}`

这只排除了前面带有引号

的链接
/(?<=[^"]|^)(https?|ftp|file):'/'/[-a-zA-Z0-9+&@#'/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#'/%=~_|]/