Regex modified to to not capture brackets

Modified the existing regex from th TLD onwards

Credit to @gruber for the regex info
https://gist.github.com/gruber/249502
This commit is contained in:
Rob McVey 2015-01-02 15:15:23 +00:00
parent 2bf41f3d85
commit 54e172b129

View file

@ -107,7 +107,7 @@ class TextHelper extends AppHelper {
$this->_placeholders = array(); $this->_placeholders = array();
$options += array('escape' => true); $options += array('escape' => true);
$pattern = '#(?<!href="|src="|">)((?:https?|ftp|nntp)://[\p{L}0-9.\-_:]+(?:[/?][^\s<]*)?)#ui'; $pattern = '#(?<!href="|src="|">)((?:https?|ftp|nntp)://[\p{L}0-9.\-_:]+(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))#i';
$text = preg_replace_callback( $text = preg_replace_callback(
$pattern, $pattern,
array(&$this, '_insertPlaceHolder'), array(&$this, '_insertPlaceHolder'),