I hate regular expressions!
Arrrghhhh!
Sorry....
Hello! :-)
I have a strange long string of which I need to match a regex pattern. This is the string
_XMMLSS.CDcatname:if(nov06cd is not null,if(extended=1 and nov06cd.ra_ext_corr > 0,catname('XLSSCD',nov06cd.ra_ext_corr,nov06cd.dec_ext_corr),catname('XLSSCD',nov06cd.ra_pnt_corr,nov06cd.dec_pnt_corr)).max
and I want to get three groups:
_XMMLSS
CDcatname:if(nov06cd is not null,if(extended=1 and nov06cd.ra_ext_corr > 0,catname('XLSSCD',nov06cd.ra_ext_corr,nov06cd.dec_ext_corr),catname('XLSSCD',nov06cd.ra_pnt_corr,nov06cd.dec_pnt_corr))
max
I've witten this code:
import java.util.regex.*;
publicclass TestRegex{
publicstaticvoid main(String[] args){
String field ="_XMMLSS.CDcatname:if(nov06cd is not null,if(extended=1 and nov06cd.ra_ext_corr > 0,catname('XLSSCD',nov06cd.ra_ext_corr,nov06cd.dec_ext_corr),catname('XLSSCD',nov06cd.ra_pnt_corr,nov06cd.dec_pnt_corr)).max";
String regex ="^(.*?)\\.(.*)\\.(.*)$";
Pattern p = Pattern.compile(regex);
String[] result = p.split(field);
}
}
which uses this pattern: "^(.*?)\\.(.*)\\.(.*)$". I'm sure it is right because I've tested it with Python and it worked as I expected... so... what's wrong? Why it doesn't split my string?
Thank you in advance.
Cheers,
Anhur

