How to write such a regex in PHP?

wargod

New Member
\[code\]$contents = 'url("/test/what)';echo preg_replace('/url\(([\'"]?)(?!(?:[a-z]+:)|\/|[\'"]\/)/i', 'url(\1'. '/prefix' . '\2', $contents);\[/code\]I want to append \[code\]/prefix\[/code\] to those urls that didn't use absolute path(start with \[code\]/\[/code\]), the above works, but is pretty ugly.Is there a more elegant solution?
 
Back
Top