import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(url\\(\\\\?['\"]?)(.*?)(\\\\?['\"]?\\))";
final String string = "/* stylelint-disable indentation */\n\n"
+ "/// Plasma design theme icons\n"
+ "@font-face {\n"
+ " @include font-weight(regular);\n"
+ " font-family: 'custom-icons';\n"
+ " font-style: normal;\n"
+ " src: url(\\\"/assets/img/raster-matrix-top-to-bottom.svg\\\")\n"
+ " format('woff'),\n"
+ " url('~@com.mgmtp.a12/plasma-design/assets/fonts/customicons/custom-icons.ttf')\n"
+ " format('truetype');\n"
+ "}\n\n"
+ "/// Material design icons\n"
+ "@font-face {\n"
+ " @include font-weight(regular);\n"
+ " font-family: 'Material Icons';\n"
+ " font-style: normal;\n"
+ " src: url('/assets/fonts/material-design-icons/MaterialIcons-Regular.eot')\n"
+ " format('eot'),\n"
+ " url('/assets/fonts/material-design-icons/MaterialIcons-Regular.woff2')\n"
+ " format('woff2'),\n"
+ " url('/assets/fonts/material-design-icons/MaterialIcons-Regular.woff')\n"
+ " format('woff'),\n"
+ " url('/assets/fonts/material-design-icons/MaterialIcons-Regular.ttf')\n"
+ " format('truetype');\n"
+ "}\n\n"
+ "/// Avenir\n"
+ "/// Regular\n"
+ "@font-face {\n"
+ " @include font-weight(regular);\n"
+ " font-family: 'Avenir';\n"
+ " font-style: normal;\n"
+ " src: url(\\\"/assets/img/raster-matrix-top-to-bottom.svg\\\") format('eot'),\n"
+ " url('/assets/fonts/avenir/avenir-regular.woff2') format('woff2'),\n"
+ " url('/assets/fonts/avenir/avenir-regular.woff') format('woff'),\n"
+ " url('/assets/fonts/avenir/avenir-regular.ttf') format('truetype');\n"
+ "}\n\n"
+ "/// Avenir\n"
+ "/// Demi\n"
+ "@font-face {\n"
+ " @include font-weight(demi);\n"
+ " font-family: 'Avenir';\n"
+ " font-style: normal;\n"
+ " src: url('/assets/fonts/avenir/avenir-demi.eot') format('eot'),\n"
+ " url('/assets/fonts/avenir/avenir-demi.woff2') format('woff2'),\n"
+ " url('/assets/fonts/avenir/avenir-demi.woff') format('woff'),\n"
+ " url('/assets/fonts/avenir/avenir-demi.ttf') format('truetype');\n"
+ "}\n\n"
+ "/// Avenir\n"
+ "/// Medium\n"
+ "@font-face {\n"
+ " @include font-weight(medium);\n"
+ " font-family: 'Avenir';\n"
+ " font-style: normal;\n"
+ " src: url('/assets/fonts/avenir/avenir-medium.eot') format('eot'),\n"
+ " url('/assets/fonts/avenir/avenir-medium.woff2') format('woff2'),\n"
+ " url('/assets/fonts/avenir/avenir-medium.woff') format('woff'),\n"
+ " url('/assets/fonts/avenir/avenir-medium.ttf') format('truetype');\n"
+ "}\n\n"
+ "/* stylelint-enable indentation */\n";
final Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
final Matcher matcher = pattern.matcher(string);
while (matcher.find()) {
System.out.println("Full match: " + matcher.group(0));
for (int i = 1; i <= matcher.groupCount(); i++) {
System.out.println("Group " + i + ": " + matcher.group(i));
}
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html