0

I'm trying to build a regular expression in js and for some reason I can't enter the underscore character, although all the other special characters can be entered. Here is my expression:

^[А-ЯЁа-я\w\d]*$

Expected result: Абвг_#$

Can you please tell me why this happens and how to fix it?

AndrosovAS
  • 110
  • 1
  • 1
  • 8
  • 1
    I guess the issue is not with underscore here, it would be with $. Because it is a token in regular expression to match end of the string. You would need to update expression like this `^[А-ЯЁа-я\w\d]*\$`. And # is not included with expression. – Wazeed Apr 21 '21 at 02:55

1 Answers1

1

You can try \W that matches any non-ASCII char. You can check this answer.