Re: substr() on part an ereg() capture

From: Date: Wed, 26 Mar 2003 23:42:59 +0000
Subject: Re: substr() on part an ereg() capture
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-141139@lists.php.net to get a copy of this message
Ahhhh that makes more sense!! Am trying everyone's suggestions now... Justin French on 27/03/03 3:32 AM, Marek Kilimajer (kilimajer@webglobe.sk) wrote: > Forgot to mention this is to be run after > eregi_replace("([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])", "<a > href=\"\\1://\\2\\3\" {$t}\">\\1://\\2\\3</a>", $str); > as it only replaces long strings within <a> tags > > > Marek Kilimajer wrote: > >> $str = >> preg_replace('|(<a[^>]*>[^<]{55})[^<]+(</a>)|','$1...$2', >> $str); >> >> Justin French wrote: >> >>> Hi, I have this ereg to turn URLs into links: >>> >>> eregi_replace("([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])", >>> "<a >>> href=\"\\1://\\2\\3\" {$t}\">\\1://\\2\\3</a>", $str); >>> >>> ... found it in the manual i think, or maybe on weberdev.com examples >>> >>> >>> Anyhoo, it places the whole link in between the <a...> and </a>, >>> which is >>> fine for short links, but on longer links (in my case, around 60+ >>> chars), it >>> messes with my table or CSS layout. >>> >>> So, I'd like to subtr() the 2nd capture part down to 55 chars or >>> something >>> IF it's longer than 60, and append a ... to it. >>> >>> ANY ideas on how this is done? Or is this beyond regexp?? >>> >>> >>> TIA >>> >>> Justin >>> >>> >>> >>> >> >> >

« previous php.general (#141139) next »