In the frontend there is a list of game titles that consist of strings:
id, game name, date, price
The search shall accept multiple keywords, e.g. user might type: 1998 Streetfighter 2
or Streetfighter 1998
Currently I create an array separated by empty space, that creates 3 keywords: [1998, Streetfighter , 2 ]
Then I go through the collection of game titles to filter matches. unfortunately it also gives back any title that includes "2" because there is no pattern recognition that identifies "Streetfighter 2" belongs together. Is there a simple algorithm to provide a pattern search?
const allGames = [
"Streetfighter 1, 1992, 20",
"Streetfighter 2, 1998, 20",
"pokemon, 2016, 20",
"Diablo 3, 2015, 40",
"Super mario, 1995, 20",
"The Witcher, 2012, 20",
]
because there is no pattern recognition that identifies "Streetfighter 2" belongs together
So are you saying you only want to match the whole string and not just parts of it? – StudioTime