Re: [PHP] wrapping anchor tags around a URL

2006-01-26 Thread Ahmed Saad
On 1/26/06, Richard K Miller [EMAIL PROTECTED] wrote: @(http://\S+)(?!\.)@ -- this still captures everything @(http://\S+?)(?!\.)@-- this captures too little hmm maybe this would work? @http://.+(?=\.)@

Re: [PHP] wrapping anchor tags around a URL

2006-01-25 Thread Ahmed Saad
On 1/23/06, Richard K Miller [EMAIL PROTECTED] wrote: function link_the_links($s) { return preg_replace('@(http://[^\s]+)@sm', 'a href=$1$1/a', $s); } I've got to somehow ignore the trailing period if it is present. if ($s[strlen($s)-1] == '.'){ $s = substr($s, 0, -1); } -ahmed

Re: [PHP] wrapping anchor tags around a URL

2006-01-25 Thread Ahmed Saad
On 1/25/06, Ahmed Saad [EMAIL PROTECTED] wrote: On 1/23/06, Richard K Miller [EMAIL PROTECTED] wrote: function link_the_links($s) { return preg_replace('@(http://[^\s]+)@sm', 'a href=$1$1/a', $s); } if ($s[strlen($s)-1] == '.'){ $s = substr($s, 0, -1); } oops! sorry i

Re: [PHP] wrapping anchor tags around a URL

2006-01-25 Thread Ahmed Saad
On 1/25/06, Ahmed Saad [EMAIL PROTECTED] wrote: On 1/25/06, Ahmed Saad [EMAIL PROTECTED] wrote: On 1/23/06, Richard K Miller [EMAIL PROTECTED] wrote: function link_the_links($s) { return preg_replace('@(http://[^\s]+)@sm', 'a href=$1$1/a', $s); } try looking ahead in the

Re: [PHP] wrapping anchor tags around a URL

2006-01-25 Thread Richard K Miller
On Jan 25, 2006, at 10:01 AM, Ahmed Saad wrote: On 1/25/06, Ahmed Saad [EMAIL PROTECTED] wrote: On 1/25/06, Ahmed Saad [EMAIL PROTECTED] wrote: On 1/23/06, Richard K Miller [EMAIL PROTECTED] wrote: function link_the_links($s) { return preg_replace('@(http://[^\s]+)@sm', 'a href=$1

[PHP] wrapping anchor tags around a URL

2006-01-23 Thread Richard K Miller
I wrote a little function to put anchor tags around a URL. We're using it to make URL's in paragraphs of text linkable: function link_the_links($s) { return preg_replace('@(http://[^\s]+)@sm', 'a href=$1$1/a', $s); } Its only flaw (besides a goofy name) is that if a link comes at the