I need to extract a param and the value for that param from a string ((created_date{[1976-03-06T23:59:59.999Z TO *]}|1)). Here param is created_date. Value is 1976-03-06T23:59:59.999Z TO * where * denotes no restriction. I need to extract the data as shown below i,e it should be an array of string.
created_date
1976-03-06T23:59:59.999Z
*
1
I have tried some online regex tool to find a suitable regex and also tried some code on trial and error basis.
String str = "((created_date{[1976-03-06T23:59:59.999Z TO *]}|1))";
String patt = "\\((.*)\\{(.*)\\}\\|(1|0)\\)";
Pattern p = Pattern.compile(patt);
Matcher m = p.matcher(str);
MatchResult result = m.toMatchResult();
System.out.println(result.group(1));
similary result.group(2) and 3.. depending on the result.groupCount().
I need to extract the data as shown below i,e it should be an array of string.
created_date
1976-03-06T23:59:59.999Z
*
1