I would like to run this regular expression https://regex101.com/r/9LJAjZ/1 using sed or perl to replace the contents of a file.
If I am correct this will never work with sed because sed is always greedy. But how can I make this regex work with perl.
This is what I've got so far:
perl -pi.bak -e "s#url\(\\[\'|\"]((?!data:|\/).*)\\[\'|\"]\)#url\(\\\'/prefix/\1\\\'\)/#g" file.js
example input file:
url(\'font-awesome.woff\') url(\'bont-awesome.woff\') url(\'/favicon.ico\') url(\'data:whatever\')
example output
url(\'/prefix/font-awesome.woff\') url(\'/prefix/bont-awesome.woff\') url(\'/favicon.ico\') url(\'data:whatever\')
), for example:sed -E "s#url\(\\\'(\[^/][^):]*\))#url\(\\\'/prefix/\1#g"