so I currently have a regex expression which replaces css urls by appending '/static/user' to each url. However, I want to make this expression ignore www urls (https://www.google.com) and catch both instances of url('Inter-Black.ttf') and url(Inter-Black.ttf), with and without quotation marks.
This is my current code:
p = re.compile(r"(?<=url\(')/?(?=(?:.*?\.\w{3})'\))")
filez = re.sub(p, '/static/user/', filez)
I have also tried which does not work.
p = re.compile(r"^(?!.*(www))(?<=url\(')/?(?=(?:.*?\.\w{3})'\))")
filez = re.sub(p, '/static/user/', filez)
And currently use this solution in order to catch both quotes and non quotes. But ideally I would want a cleaner solution along with regex ignoring www urls.
p = re.compile(r"(?<=url\(')/?(?=(?:.*?\.\w{3})'\))")
filez = re.sub(p, '/static/user/', filez)
p = re.compile(r"(?<=url\()/?(?=(?:.*?\.\w{3})\))")
filez = re.sub(p, '/static/user/', filez)
Thank you for your time.