import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "code\\/\\\":(?<code>[\\d]+)";
final String string = "2014-10-29T19:20:36+00:00 DEBUG (7): ERP_SERVICE_CALL:POST:RESPONSE: \"{/\"status/\":/\"success/\",/\"code/\":400,/\"data/\":{/\"batch_id/\":/\"M-1331/\",/\"order_total/\":4,/\"success_total/\":0,/\"orders/\":[{/\"order_id/\":/\"1272749/\",/\"status/\":/\"error/\",/\"message/\":/\"order_id: 1272749 //nCode: INVALID_KEY_OR_REF//nDetails: Invalid item reference key. Item value provided: ASB-000219 //nforEach(EC_Libs-4.0.6.js:70),forEach(EC_Libs-4.0.6.js:70),restletwrapper(null$lib:4) //n[no stack trace]/\",/\"customer_internal_id/\":/\"16873/\",/\"customer_id/\":1301051},{/\"order_id/\":/\"1272750/\",/\"status/\":/\"error/\",/\"message/\":/\"order_id: 1272750 //nCode: INVALID_KEY_OR_REF//nDetails: Invalid item reference key. Item value provided: ASB-000219 //nforEach(EC_Libs-4.0.6.js:70),forEach(EC_Libs-4.0.6.js:70),restletwrapper(null$lib:4) //n[no stack trace]/\",/\"customer_internal_id/\":/\"16873/\",/\"customer_id/\":1301051},{/\"order_id/\":/\"1272751/\",/\"status/\":/\"error/\",/\"message/\":/\"order_id: 1272751 //nCode: INVALID_KEY_OR_REF//nDetails: Invalid item reference key. Item value provided: ASB-000219 //nforEach(EC_Libs-4.0.6.js:70),forEach(EC_Libs-4.0.6.js:70),restletwrapper(null$lib:4) //n[no stack trace]/\",/\"customer_internal_id/\":/\"16873/\",/\"customer_id/\":1301051},{/\"order_id/\":/\"1272752/\",/\"status/\":/\"error/\",/\"message/\":/\"order_id: 1272752 //nCode: INVALID_KEY_OR_REF//nDetails: Invalid item reference key. Item value provided: ASB-000219 //nforEach(EC_Libs-4.0.6.js:70),forEach(EC_Libs-4.0.6.js:70),restletwrapper(null$lib:4) //n[no stack trace]/\",/\"customer_internal_id/\":/\"16873/\",/\"customer_id/\":1301051}]}}\"";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(string);
if (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