Well, I have noticed this during using console.
> var a = new RegExp('\\b' + "абв" + '\\b', "gim");
> a.test("абв");
false
> var b = new RegExp("абв", "gim");
> b.test("абв");
true
And then with latin characters:
> var c = new RegExp('\\b' + "abc" + '\\b', "gim");
> c.test("abc");
true
I would glad to read your suggestions about fixing this.
\\b
refers only to word boundaries in an ASCII perception. You can create DIY boundaries. Also if you already know the pattern will remain constant, use a regular expression literal as follows:
/(^| )абв( |$)/.test("абв"); // true
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.