I'm trying to create a function which will search a specific words.
For example if I tap the letter "O" the first result will be the word "Oasis" (and not "U2 - Still Haven't Found What I'm..." and all the other songs that has "O" in their words), or any other middle word.
It need to ignore spaces - " ", the char "-" (" "-" ") and ' or other chars, so it will connect all thw words together.
For example when I tap "dontlookbackin" the search will find the word which is starting with the first letter I pressed, than the other letter in the word and so on.
So far I'm only able to make a simple search - to find every word that contains the first letter I pressed.
The specific part of the "search" function :
SearchSong = () => {
console.log("Pressed")
var e = this.state.searchRes;
if (e == "") {
return;
}
var musicList = [];
var songs = [];
if (this.state.songs != null) {
songs = this.state.songs;
musicList = songs.filter(song =>
song.Song_Name.toLowerCase().includes(e.toLowerCase())
);
Example of the current search -
If more detials and fixes are needed please tell me.