What I am trying to do is to find loop through a string then match them with an arrayList.
Say, I got this code working:
import java.io.*;
import java.text.ParseException;
import java.util.*;
public class Test_Mark4 {
public static ArrayList<String> patterntoSearch;
public static void main(String[] args) throws IOException, ParseException {
String text = "Lebron James";
patterntoSearch = new ArrayList();
patterntoSearch.add("Lebron James");
patterntoSearch.add("Michael Jordan");
patterntoSearch.add("Kobe Bryant");
System.out.println(patterntoSearch);
System.out.println(text);
boolean valueContained = patterntoSearch.contains(text);
System.out.println(valueContained);
}
}
However, what if I replace String text = "Lebron James"; with String text = "Lebron James 2017-218 NBA Hoops Card";? Clearly there is the string Lebron James in that string, but it got mixed with other words as well (which I would not care, and only care about the string Lebron James. I have thought about a for loop but unsure how to construct it.