Re: For the RegExps gurus!

From: Date: Thu, 06 Sep 2001 17:30:44 +0000
Subject: Re: For the RegExps gurus!
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-66260@lists.php.net to get a copy of this message
On Wed, 5 Sep 2001 12:15:34 +0200 impersonator of renze@datalink.nl (* R&Ze:) planted &I saw in php.general: >This should do the job: > ... You can keep improving:) or you can use piece of my working (except for $Harlem, to which i am not going:) code (I give it for free this time:) No /me, no ereg, no nothing - gentleMen:)-just /i (did you miss it, btw?:) note1: your url shouldn't be broken in the middle by \n note2: you might see strange characters in patterns - its allowed by standart - cyrilic. If you are sure to not need anything but latinic, take others out. -------- $pref = "([a-z0-9~#%\&=\?/\._-]+?:([a-z0-9~#%\&=\?/\._-]+?@)?)?"; $port = "(:[\d]+)?"; $domain = "([_0-9a-zÿâåðòûóèîïøùýúüþ¸àñäôã÷éêëìíáæöõç][_0-9a-zÿâåðòûóèîïøùýúüþ¸àñäôã÷éêëìíáæöõç-]+?[\.])+[a-z]{2,3}"; $subpat = $domain . $port . "([/\\][a-zÿâåðòûóèîïøùýúüþ¸àñäôã÷éêëìíáæöõç0-9~#%@\&:\.=\?_-]*)*"; $patterns = array ("`(?<=[;\x20^<>{}+-=|\\&%^\^\$#!~:.,\(\)\"'\[])((f|ht)tps?|news)://" . $pref . $subpat ."`i", "(?<=[;\x20^<\(\)\"'\[])www[\.]" . $subpat . "i", "(?<=[;\x20^<\(\)\"'\[])[_\.0-9a-z-]+@" . $domain . "i"); $links = array ("<a href='\\0'>\\0</a>", "<a href='http://\\0'>\\0</a>", "<a href='mailto:\\0'>\\0</a>"); $Harlem=explode("\n",$mem); foreach($Harlem as $line){ $line = htmlspecialchars ( $line); $line = preg_replace ($patterns, $links, $line); } >-- »»»»»»»»»»»»»»»»»»»»»»»» >-- Renze Munnik >-- DataLink BV >-- >-- E: renze@datalink.nl >-- W: +31 23 5326162 >-- F: +31 23 5322144 >-- M: +31 6 21811143 >-- >-- Stationsplein 82 >-- 2011 LM HAARLEM >-- Netherlands >-- >-- http://www.datalink.nl >-- «««««««««««««««««««««««« -- i leonid http://nux.home.dk3.com/ no phone here, but for other personals - donation info. - visit i site^:)

« previous php.general (#66260) next »