I convert a excel file to a CSV , and that to a String.
The problem is that a regular expression is not working correctly
I want to detect this kind of text:
MYW Pkg, MYW Pkg + Quick Service Dining, MYW Pkg + Dining, MYW Pkg + Deluxe Dining,
Room + Tickets + Quick Service Dining
I have an array of String. So I need to know a pattern for that, I try this but it doesn't detect it:
Pattern.compile("([A-Z]{3})+(\\s)+([A-Za-z]{3})+(\\s)+(\\+)");
I try to match "MYW Pkg +" for example, Do you know why it is not working?
More code:
chain is the array with values like "MYW Pkg,"
Pattern patPackageDescription = Pattern.compile("([A-Z]{3})+(\\s)+([A-Za-z])+(\\s)+(\\+)");
for (int i = 0; i < chain.length; i++) {
Matcher matPackageDescription = patPackageDescription
.matcher(chain[i]);
if (matPackageDescription.matches()) {
String space = String.format("%1$-" + 50 + "s",
chain[i].toString());
a.append(space + "|\n");
}
}
Regards.