I have need to be able to replace text within a string to turn it into a
link.  In other words, I might have a phrase lik:

"blah, blah, blah, please visit my site at www.mysite.com.  blah,
blah,blah".

I need to have the string converted to "blah, blah, blah, please visit my
site at http://www.mysite.com.  blah, blah,blah".  The link might have more
than 3 sections and won't necessarily end in .com (.net,.com.nl, etc.).

Here is what I have been testing (then I get stuck):
$myLink = "Please visit my web site at www.mysite.com. You will be glad you
did!";
$repLink = preg_replace("/(www.)/i","<a href=http://\\1",$myLink);

which yields
Please visit my web site at <a href=http://www.mysite.com. You will be glad
you did!

What I would need is
Please visit my web site at <a
href=http://www.mysite.com>www.mysite.com</a>. You will be glad you did!

To be truthful, pattern matching is giving me migraines!  Programming has
always been natural to me (32 years of it), but this challenge (eregi,
preg_match,etc.) is making me crazy!  Can someone recommend a good tutorial
or book on this subject?

Thanks!




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to