Tuesday, April 28, 2009

Java regex tip

While working on a message parser based on java regex i had the need of breaking down messages and being able to ignore certain results from the group because i did not want those values to be considered. Searching on the net did not yield any results hence i went to one of my superiors at work and got to know the answer to this and hence wanted to share it with all of you so that the next time any one does search for a similar problem they might stumble upon this blog ;) ... So the solution is as follows;
 
String simplReg = ([A-B]{4} (?:(0-9){2}));
 
The '?:' operators are used in the second group to specify to java regex that the second group should be ignored from the final result. Thats it guys... Until my next post its adios from my side :D

No comments:

Post a Comment