I'm trying to take a file that store data of this form:
Name=”Biscuit”
LatinName=”Retrieverus Aurum”
ImageFilename=”Biscuit.png”
DNA=”ITAYATYITITIAAYI”
and read it with a regex to locate the useful information; namely, the fields and their contents.
I have created the regex already, but I can only seem to get one match at any given time, and would like instead to put each of the matches from each line in the file in their own index of a string.
Here's what I have so far:
Scanner scanFile = new Scanner(file);
while (scanFile.hasNextLine()){
System.out.println(scanFile.findInLine(".*"));
scanFile.nextLine();
}
MatchResult result = null;
scanFile.findInLine(Constants.ANIMAL_INFO_REGEX);
result = scanFile.match();
for (int i=1; i<=result.groupCount(); i++){
System.out.println(result.group(i));
System.out.println(result.groupCount());
}
scanFile.close();
MySpecies species = new MySpecies(null, null, null, null);
return species;
Thanks so much for your help!