On Sat, Aug 22, 2015 at 6:04 AM, Stefan Monnier wrote: > The question was not whether the regexp works, but what does the CSS > language want us to do. I.e. is "url(foo)bar)" equivalent to > "url('foo)bar')" or to "url('foo')bar)"? Ah, good that you asked, because the CSS spec states the following: Some characters appearing in an unquoted URI, such as parentheses, white space characters, single quotes (') and double quotes ("), must be escaped with a backslash so that the resulting URI value is a URI token: '\(', '\)'. So in "url(foo)bar)", the URI ends at the first ")", while in "url(foo\)bar)", it ends at the last ")". The following regexp seems to handle this: "url\\((\\)[[:space:]]*\\(?:\\\\.\\|[^()[:space:]\n'\"]\\)+[[:space:]]*\\()\\)" -- Simen