I\'m parsing out text from a file and trying to look at the times. I first need to check if there are times in the text. The only consistent pattern in the text is that all time
To find such a pattern you're best off using a regular expression, something like this:
Pattern timePattern = Pattern.compile("[0-2][0-9]:[0-5][0-9]");
Now you can create a Matcher to see whether this Pattern is found within a CharSequence, like this:
Matcher timeMatcher = timePattern.matcher(textWithTime);
while(timeMatcher.find()) {
System.out.println("Found time " + timeMatcher.group() + " in the text!";
}
Have a look at the API for java.util.regex to see the other methods which Pattern and Matcher provide. Regular expressions are very powerful.