import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(^\\\"|\\{)";
final String string = "\"@odata.context\": \"https://example-app-env.aa01.aaa.aaaa-ad/odata/$metadata#Jobs\",\n"
+ " \"@odata.count\": 111,\n"
+ " \"value\": [\n"
+ " {\n"
+ " \"Key\": \"aaa1a111-aa11-11aa-a11a-11a1aa11a111\",\n"
+ " \"StartTime\": \"2023-01-20T14:08:34.607Z\",\n"
+ " \"EndTime\": \"2023-01-20T14:08:49.517Z\",\n"
+ " \"State\": \"Successful\",\n"
+ " \"JobPriority\": \"Normal\",\n"
+ " \"Source\": \"Agent\",\n"
+ " \"SourceType\": \"Agent\",\n"
+ " \"BatchExecutionKey\": \"aaa1a111-aa11-11aa-a11a-11a1aa11a111\",\n"
+ " \"Info\": \"Job completed\",\n"
+ " \"CreationTime\": \"2023-01-20T14:08:34.607Z\",\n"
+ " \"StartingScheduleId\": null,\n"
+ " \"ReleaseName\": \"RobotProdLogin_DEV\",\n"
+ " \"Type\": \"Attended\",\n"
+ " \"InputArguments\": \"\",\n"
+ " \"OutputArguments\": \"{}\",\n"
+ " \"HostMachineName\": \"AAAAAAAA11111\",\n"
+ " \"HasMediaRecorded\": false,\n"
+ " \"PersistenceId\": null,\n"
+ " \"ResumeVersion\": null,\n"
+ " \"StopStrategy\": null,\n"
+ " \"RuntimeType\": \"Development\",\n"
+ " \"RequiresUserInteraction\": true,\n"
+ " \"ReleaseVersionId\": 1111,\n"
+ " \"EntryPointPath\": null,\n"
+ " \"OrganizationUnitId\": 1,\n"
+ " \"OrganizationUnitFullyQualifiedName\": \"Default\",\n"
+ " \"Reference\": \"\",\n"
+ " \"ProcessType\": \"Process\",\n"
+ " \"ProfilingOptions\": null,\n"
+ " \"ResumeOnSameContext\": false,\n"
+ " \"LocalSystemAccount\": \"AAAAAA01\\\\AAA11AA\",\n"
+ " \"OrchestratorUserIdentity\": null,\n"
+ " \"Id\": 00000\n"
+ " },\n"
+ " {\n"
+ " \"Key\": \"aaa1a111-aa11-11aa-a11a-11a1aa11a111\",\n"
+ " \"StartTime\": \"2023-01-20T14:08:34.607Z\",\n"
+ " \"EndTime\": \"2023-01-20T14:08:49.517Z\",\n"
+ " \"State\": \"Successful\",\n"
+ " \"JobPriority\": \"Normal\",\n"
+ " \"Source\": \"Agent\",\n"
+ " \"SourceType\": \"Agent\",\n"
+ " \"BatchExecutionKey\": \"aaa1a111-aa11-11aa-a11a-11a1aa11a111\",\n"
+ " \"Info\": \"Job completed\",\n"
+ " \"CreationTime\": \"2023-01-20T14:08:34.607Z\",\n"
+ " \"StartingScheduleId\": null,\n"
+ " \"ReleaseName\": \"RobotProdLogin_DEV\",\n"
+ " \"Type\": \"Attended\",\n"
+ " \"InputArguments\": \"\",\n"
+ " \"OutputArguments\": \"{}\",\n"
+ " \"HostMachineName\": \"AAAAAAAA11111\",\n"
+ " \"HasMediaRecorded\": false,\n"
+ " \"PersistenceId\": null,\n"
+ " \"ResumeVersion\": null,\n"
+ " \"StopStrategy\": null,\n"
+ " \"RuntimeType\": \"Development\",\n"
+ " \"RequiresUserInteraction\": true,\n"
+ " \"ReleaseVersionId\": 1111,\n"
+ " \"EntryPointPath\": null,\n"
+ " \"OrganizationUnitId\": 1,\n"
+ " \"OrganizationUnitFullyQualifiedName\": \"Default\",\n"
+ " \"Reference\": \"\",\n"
+ " \"ProcessType\": \"Process\",\n"
+ " \"ProfilingOptions\": null,\n"
+ " \"ResumeOnSameContext\": false,\n"
+ " \"LocalSystemAccount\": \"AAAAAA01\\\\AAA11AA\",\n"
+ " \"OrchestratorUserIdentity\": null,\n"
+ " \"Id\": 00000\n"
+ " },";
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