user16733810
user16733810

Reputation:

regex in Arabic letters

In English it works well, but in Arabic I don't know why

const myText = "here";
console.log(/\bhere\b/.test(myText)); // true

// in Ar
const myText = "السلام";
console.log(/\bالسلام\b/.test(myText)); // false

Upvotes: 0

Views: 55

Answers (1)

Vitaliy Kondratev
Vitaliy Kondratev

Reputation: 96

Just use unicode entities:

const myText = "السلام";
console.log(/\s*\u0627\u0644\u0633\u0644\u0627\u0645\s*/.test(myText)); //true

Upvotes: 1

Related Questions