Похожие чаты

Can someone explain me why below snippet doesn't capture #apple? "eat

#apple and #banana!".match(new RegExp(/#((?:[^\s\p{P}]|_)+)/u, "g"))

2nd parameter in RegExp will override the flags?

5 ответов

7 просмотров

what is {P} supposed to be?

decoder- Автор вопроса
Thomas
what is {P} supposed to be?

Any punctuation character like ".", "," etc

Why are you using both the RegExp constructor and an inline regexp? Remove the constructor and add the flag to the inline regex. /#((?:[^\s\p{P}]|_)+)/ug, and you get this result: > "eat #apple and #banana!".match(/#((?:[^\s\p{P}]|_)+)/ug) < [ "#apple", "#banana" ]

decoder- Автор вопроса
Simen
Why are you using both the RegExp constructor and ...

RegEx is constant and it is used in multiple places. If I might do some changes other functionality might break. So I didn't touch it.

Похожие вопросы

Обсуждают сегодня

Карта сайта