I have a search which return some products from API, these products in Arabic
the Arabic language has many letters looks like the same, for example ( أ – ا ), (ي – ى ), ( ه – ة). I need when I write ه it will search for ( ه and ة) and return the products which contain the ه or ة in table
Example: there’s 5 products containing (ه), and 5 products containing (ة) so I need when I type any letter of them it returns 10 products. How to do this?
I tried this:
const normalizeSearchPhrase = (phrase) => {
return phrase
.replace(/أ|ا/g, "ا")
.replace(/ي|ى/g, "ي")
.replace(/ة|ه/g, "ه");
};
I expected it to return any product containing أ or ا when I type any of them to get the 10 product but it replace a letter with the other one so it return 5 products not the 10 as example above.
3làá 3dêl is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2