import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "\"width\"\\s*:\\s*(?'width'\\d+).+?\"height\"\\s*:\\s*(?'height'\\d+).+?\"url\"\\s*:\\s*\\\"(?'url'.+?)\"";
final String string = "<pre>#34;, \"createdAt\": \"2018-07-30T13:33:21.373947\"}, {\"uid\": \"c442c352934545b183e16ce9aebd91cb\", \"width\": 2048, \"options\": {\"format\": \"R\", \"quality\": 88}, \"updatedAt\": \"2018-08-01T17:51:24.738232\", \"height\": 2048, \"size\": 618478, \"url\": \"https://media.sketchfab.com/urls/ea1adc30399045a2b101e16ba65a856f/dist/textures/a4291782af5f4ce39e637c89ec91fa9b/c442c352934545b183e16ce9aebd91cb.jpeg\", \"createdAt\": \"2018-08-01T17:51:25.334608\"}, {\"uid\": \"84275b9d01b54836893e355991288c2f\", \"width\": 1024, \"options\": {\"format\": \"R\", \"quality\": 92}, \"updatedAt\": \"2018-08-01T17:51:25.341010\", \"height\": 1024, \"size\": 220485, \"url\": \"https://media.sketchfab.com/urls/ea1adc30399045a2b101e16ba65a856f/dist/textures/a4291782af5f4ce39e637c89ec91fa9b/84275b9d01b54836893e355991288c2f.jpeg\", \"createdAt\": \"2018-08-01T17:51:25.451079\"}, {\"uid\": \"88897653dc004ded9faee4eaf2fa0373\", \"width\": 512, \"options\": {\"format\": \"R\", \"quality\": 95}, \"updatedAt\": \"2018-08-01T17:51:25.456671\", \"height\": 512, \"size\": 83896, \"url\": \"https://media.sketchfab.com/urls/ea1adc30399045a2b101e16ba65a856f/dist/textures/a4291782af5f4ce39e637c89ec91fa9b/88897653dc004ded9faee4eaf2fa0373.jpeg\"";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
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