Hi list,
I am rewriting a Perl script in Java.
I am using java.util.regex.Pattern and java.util.regex.Matcher for regex.
My code looks like followig:
Code:
Pattern p = Pattern.compile("^S\\s+\\[(.*?)\\],\\s+C\\s+\\[(.*?)\\]\\[(.*?)\\]\\s+:\\s+\\(R (.+)\\)\\(V (.+)\\)(\\(A .+\\))?\\(U (.+)\\)\\s*\\[level \\d+)\\].*$"
String text="S [Oct 18 17:30:36], C [10/18/06 5:30 PM][hardik] : (R 25891031)(V 1100)(A )(U 1100) [level:7][SelectDisplay] The list ContractList_FilterField : the length is 7"
Matcher m = p.matcher(text);
if(m.matches())
for (int i=1; i<=5; i++)
LOGGER.debug("grp "+i+ " value "+m.groups(i));
the output looks like this
Code:
DEBUG - grp 0 value S [Oct 18 17:30:36], C [10/18/06 5:30 PM][hardik] : (R 25891031)(V 1100)(A )(U 1100) [level:7][SelectDisplay] The list ContractList_FilterField : the length is 7
DEBUG - grp 1 value Oct 18 17:30:36
DEBUG - grp 2 value 10/18/06 5:30 PM
DEBUG - grp 3 value hardik
DEBUG - grp 4 value 25891031
DEBUG - grp 5 value 1100)(A // look at this I expect this tobe only 1100
can anybody tell me what is wrong with the regex and what should I change to get 1100 in the 5th group ?
regards,
Hardik