Answer the question
In order to leave comments, you need to log in
How to escape regex in bash script for sed?
It is required to replace all found occurrences by regular expression with :url()
Regular
/[:,\s]\s*url\s*\(\s*(?:'(\S*?)'|"(\S*?)"|((?:\\\s|\\\)|\\"|\\'|\S)*?))\s*\)/gi
npm run bla-bla-bla | sed -r "s/[:,\s]\s*url\s*\(\s*(?:'(\S*?)'|\"(\S*?)\"|((?:\\\s|\\\)|\\\"|\\'|\S)*?))\s*\)/:url()/gi" > file.css
Answer the question
In order to leave comments, you need to log in
Wrap the regular expression in $'...' with single quote escaping:
npm run bla-bla-bla | sed -r $'"s/[:,\s]\s*url\s*\(\s*(?:'(\S*?)'|\"(\S*?)\"|((?:\\\s|\\\)|\\\"|\\'|\S)*?))\s*\)/:url()/gi"' > file.css
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question