Hello fellow programmers,
I would like to ask for some help with regards to near matches of strings.
Currently, I have a program that stores strings of description, users can search for description by typing it completely or partially.
I would like to implement a near match search. For example the actual description is "hello world" but user erroneously enter a search "hello eorld". The programs should be able to return "hello world" to user.
I've tried looking at pattern and matches to implement it, but it requires a regex to match strings, whereby my description does not have a regular pattern. I've also tried string.contains, but it doesn't seems to work either. Below is part of the code i tried to implement.
ArrayList <String> list = new ArrayList<String>();
list.add("hello world");
list.add("go jogging at london");
list.add("go fly kite");
Scanner scan = new Scanner(System.in);
for(int i = 0; i < list.size(); i++){
if(list.get(i).contains(scan.next())) {
System.out.println(list.get(i));
}
}
Could fellow programmers help me with this??