I am trying to do pattern match on pipe delimited string in java . But not sure what's going wrong. Need help from experts.
A|Bill Access Key|CBEBALCOM|
D|215325775|20210507|9|BALCOM SYSTEMS LTD|||
I|1|Back of Duplex Page|
I have file with records as above and I want to find record starting with 'D' and get the next pipe delimited values. And store those in some pojo object.
So tried to first read values by applying pattern but unable to find match.
String pattern = "r'D((?:"(.*?)"))'";
Pattern r = Pattern.compile(pattern); Matcher m = r.matcher(line);
if (m.find( )) {
System.out.println("value1" + m.group(0) );
System.out.println("value2" + m.group(1) );
} else {
System.out.println("No Match");
}
Aucun commentaire:
Enregistrer un commentaire