I am going through a project and replacing internal links to go through a url function. I have created a bit of regex which does what I need, however I don't want it to do anything with dynamic links, as I'm going to go through and do them manually.
My regex is:
(href|src)=(?:'|")\/(?!http)(.+?)(?:'|")
My replace is:
$1="<?php echo url('$2'); ?>"
This works fine for:
<link rel='stylesheet' type='text/css' href='/public/css/print.css' media="print"/>
<link rel='stylesheet' type='text/css' href='http://example.com/public/css/print.css' media="print"/>
I want it to ignore the following though:
<link rel='stylesheet' type='text/css' href='/public/css/print<?php echo 1; ?>.css' media="print"/>
Bonus points if someone can provide a seperate regex and replace which takes the echo and places it in a string concatination of the url function! Something along the lines of
$1="<?php echo url('$2' . $3 . '$4'); ?>"