note 55028 deleted from reference.pcre.pattern.syntax by colder

From: Date: Mon, 18 Jun 2007 18:01:48 +0000
Subject: note 55028 deleted from reference.pcre.pattern.syntax by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-127561@lists.php.net to get a copy of this message
Note Submitter: davout_69 at yahoo dot 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 (#127561) next »