In Java I am using Pattern and Matcher to find all instances of “.A (a number)” in a set of strings to retrieve the numbers.
I run into problems because one of the words in the file is “P.A.M.X.” and the number returns 0. It won’t go through the rest of the file. I’ve tried using many different regular expressions but I can’t get past that occurrence of “P.A.M.X.” and onto the next “.A (number)”
for (int i = 0; i < input.size(); i++) {
Pattern pattern = Pattern.compile("\\.A\\s\\d+");
Matcher matcher = pattern.matcher(input.get(i));
while (matcherDocId.find())
{
String matchFound = matcher.group().toString();
int numMatch = 0;
String[] tokens = matchFound.split(" ");
numMatch = Integer.parseInt(tokens[1]);
System.out.println("The number is: " + numMatch);
}
}
Short sample for you: