0

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
  • Does this answer your question? [Regex match Arabic keyword](https://stackoverflow.com/questions/40731058/regex-match-arabic-keyword) – cloned Jan 30 '22 at 09:18

1 Answers1

1

Just use unicode entities:

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