I am trying to modify a regex expression so that it retains commas used within parenthesis and separate all other values.
Existing pattern : ([^\\s,]+)\\s*=>([^,]+)
Updated pattern : ([^\\s,]+)\\s*=>([^(,)]+)
Java code:
public static void main(String[] args) {
String softParms = "batch_code => 'batchCd',user_id => 'SYSUSER',thread_pool => 'tpName',business_date => FN_DATE_ARG(null,0),rerun_number => 0,max_timeout_mins => 0,raise_error => false,thread_notifications => false";
//Pattern paramPattern = Pattern.compile("([^\\s,]+)\\s*=>([^,]+)");
Pattern paramPattern = Pattern.compile("([^\\s,]+)\\s*=>([^(,)]+)");
Matcher matcher = paramPattern.matcher(softParms);
while (matcher.find()) {
String param = matcher.group(1);
String value = matcher.group(2);
System.out.println("Param: " + param + ", Value: " + value);
}
}
The param value for business_date should come as FN_DATE_ARG(null,0) but the function is either returning FN_DATE_ARG(null or FN_RMB_DATE_ARG
Would appreciate any help on this!