note 55027 deleted from reference.pcre.pattern.syntax by betz

From: Date: Fri, 22 Jul 2005 19:35:58 +0000
Subject: note 55027 deleted from reference.pcre.pattern.syntax by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-92316@lists.php.net to get a copy of this message
Note Submitter: davout_69 at at at yahoo dot the com ---- Found a great expression that replaces a text url - http:/.... with <a href ="http://www..."> Although it works, I still don't understand how. If someone could explain this it would great to learn what amounts to me as a foreign language :-) Here is the expression: '%&quot;(.+)&quot;[\s]+((http|https|ftp|file)://[^\s]+?)(.*)%sU' $pcre = '%&quot;(.+)&quot;[\s]+((http|https|ftp|file)://[^\s]+?)(.*)%sU'; if ( preg_match( $pcre, $lines ) ){ $lines = preg_replace( $pcre, '<a href="$2" target="_top">$1</a>$4', $lines ); } else { $pcre = '%\b((http|https|ftp|file)://[^\s]+?)(.*)%U'; $lines = preg_replace( $pcre, '<a href="$1" target="_top">$1</a>$3', $lines ); }

« previous php.notes (#92316) next »