Skip to content

Instantly share code, notes, and snippets.

View msalahat's full-sized avatar

Mutaz Salahat msalahat

View GitHub Profile
@KhaledElAnsari
KhaledElAnsari / match_arabic_hmaz_letter.js
Last active March 23, 2017 19:28 — forked from msalahat/match_arabic_hmaz_letter.js
Match user search with hamza in Arabic ( أ، ا ، آ ، إ ) against a list of words - UTF8
let match_arabic = (user_input, word) => {
let user_input_regx = "";
// البحث عن أ، ا ، آ و إ
let hamz_letters = ["أ", "ا", "آ", "إ"].join("|")
const hamz_regx = new RegExp(hamz_letters);
for (let d = 0, len = user_input.length; d < len; d++) {
user_input_regx += ( hamz_regx.test(user_input.charAt(d)) ? "[" + hamz_letters + "]" : user_input.charAt(d) );
}