ROWS: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Show these: www.google.com www.slashdot.com http://yahoo.com Tests: www.showme.com "www.hideme.com" www.showme.com "www.hideme.com" www.showme.com "www.hideme.com"
Execution Time(sec.): 0.000857 Raw Match Pattern: (?!(?:(?!")[^"])*("|")(?:(?:(?!\1).)*\1(?:(?!\1).)*\1)*(?:(?!\1).)*$)(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’])) PHP Code Example: <?php $sourcestring="your source string"; preg_match_all('~(?!(?:(?!")[^"])*("|")(?:(?:(?!\1).)*\1(?:(?!\1).)*\1)*(?:(?!\1).)*$)(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))~sx',$sourcestring,$matches); echo "<pre>".print_r($matches,true); ?> $matches Array: ( [0] => Array ( [0] => www.google.com [1] => www.slashdot.com [2] => http://yahoo.com [3] => www.showme.com [4] => www.showme.com [5] => www.showme.com ) [1] => Array ( [0] => [1] => [2] => [3] => [4] => [5] => ) [2] => Array ( [0] => www.google.com [1] => www.slashdot.com [2] => http://yahoo.com [3] => www.showme.com [4] => www.showme.com [5] => www.showme.com ) [3] => Array ( [0] => [1] => [2] => [3] => [4] => [5] => ) [4] => Array ( [0] => [1] => [2] => [3] => [4] => [5] => ) [5] => Array ( [0] => [1] => [2] => [3] => [4] => [5] => ) [6] => Array ( [0] => [1] => [2] => [3] => [4] => [5] => ) )