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