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"> $1</a>', $s);
}

try "looking ahead" in the first regex
http://www.regular-expressions.info/lookaround.html


Wow, I was really glad you found that. I had never heard of this before, but it looks like the solution.

However, my real life example still isn't working, even after adding what I think was the right look-ahead expression:

@(http://\S+)(?!\.)@   -- this still captures everything

@(http://\S+?)(?!\.)@    -- this captures too little

Any ideas?  In any case, thanks for the article -- that was informative.

Richard

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to