Reputation: 93421
i have this regex :
url\(\s*(['"]?+)(.*?)\1\s*\)
Which retrieves all url from css file .
I use this code , However i get an error :
Pattern p = Pattern.compile("url\(\s*(['\"]?+)(.*?)\1\s*\)");
Matcher m = p.matcher(cssText);
while (m.find()) {
println m.group()
}
As you can note that i add \
to esacpe "
. But in vain
Upvotes: 1
Views: 92
Reputation: 785761
You need to use \\
instead of \
in Java regex:
Pattern p = Pattern.compile( "url\\(\\s*(['\"]?+)(.*?)\\1\\s*\\)" );
\
is for escaping from String object\
is for escaping from underlying regex engineUpvotes: 3