<?php $html=<<<HTML <img src="/relative/url/img.jpg" /> <form action="/"> <a href='/relative/url/'>Note the Single Quote</a> <img src="//site.com/protocol-relative-img.jpg" /> HTML; $base='https://example.com'; echo preg_replace('~(?:src|action|href)=[\'"]\K/(?!/)[^\'"]*~',"$base$0",$html);
You have javascript disabled. You will not be able to edit any code.