Hello , i need an preg replace algoritm that will replace short links to full links. Like , it will replace /home, to website.com/home, and page.html to website.com/page.html , the problem is that on that page there can be pages with src="http:// (full url) and src="" short urls
$text = preg_replace( '/<a([^>]+)href="(?!(http:))/i', '<a$1href="http://www.example.com/$2', $text ); PHP:
I mean it's working , but it's not replacing the images, only the URLs $website = preg_replace( '/<a([^>]+)src="(?!(http)/i', '<a$1src="http://www.softgroups.com/$2', $website ); i try this also , but without luck
It works for me. Maybe you want to replace the old search pattern with this to make it work with https links too. '/<a([^>]+)href="(?!(https?:))/i' PHP: What kind of output do you get?
Give this a try. $text = preg_replace( '/\s(href|src)=["\']?\/?(?!(https?:))([^>"\'\s]+)/i', ' $1="http://www.example.com/$3"', $text ); PHP:
Wow you really good. One question what if I want to add after this an <img src=""> to show an visual pagerank what should i do ?