I am currently developing a Vue-Vuetify application with a PHP backend. I have a list of contacts that include first names, last names, and other details that are not relevant at the moment. My main query is how to search through this list while disregarding any special characters. Let me provide an example: Name: Janko Hraško (in my language, we use names with special characters like ľščťžýáí...). Currently, when I search in the list, I can only search by either first name or last name. For instance, if I type "Janko," I will find the person, and similarly for "Hraško." My first question is, is there a way to merge the two together? For example: If I type "Jan" (the person will appear, but there may be multiple people with the same starting name), and then I enter a space followed by "Hra" (to narrow down to just one person). Essentially, what I'm trying to achieve is a combined search functionality for both first and last names without having to input the full name. Secondly, how can I disregard special characters? Currently, searching for "Hrasko" yields no results, but as soon as I enter "Hraško," the specific person shows up. Is it feasible to ignore all special characters during the search process? Like being able to find "Hrasko" even if the actual name includes special characters like "Hraško"?
Below is a snippet of my code (Vue.app):
computed: {
filteredContacts (){
if(this.search){
return this.contact_list.filter((item)=>{
return item.firstname.toLowerCase().startsWith(this.search) || item.lastname.toLowerCase().startsWith(this.search) ||
item.firstname.startsWith(this.search) || item.lastname.startsWith(this.search);
})
}else{
return this.resources;
}
}
Any assistance would be greatly appreciated! Thank you.