I need to automatically parse a string and find if a link to my site is present, automatically replace the address by a clickeable HTML link.
Supposing my site adresses are www.mysite.com + wap.mysite.com + m.mysite.com, I need to convert:
My pictures at m.mysite.com/user/id are great.
to:
My pictures at <a href="/user/id" target="_blank">mysite.com/user/id</a> are great.
The question is how to do this (with ereg_replace?) instead of using tons of lines of code.
Notice that the result must be a relative URL, so that the current protocol and subdomain is used for the target link. If the user is in the m subdomain of the HTTPS version, the target will be the m subdomain of the HTTPS protocol and so on. Only links to mysite.com must be linked, any other links must be treated as ordinary plain text. Thanks in advance!