Reputation: 2700
I have some problems with regexp. I'm try to remove all special characters without "- _" it works but only with Latin letters. Can someone help me how to do that.
I need remove all without letters numbers and "- _".
for example
string = "asd;'\;['/\''сдфсдфявэ';щш;э'սդֆսդֆսդֆ«»խլխլ";
Upvotes: 2
Views: 1382
Reputation: 626747
You may use
var s = "՞։՜asd;'\;['/\''сдфсдфявэ';щш;э'սդֆսդֆսդֆ«»խլխլ";
var ret = s.replace(/[^\wа-яёА-ЯЁ\u0561-\u0587\u0531-\u0556-]+/g, '');
document.body.innerHTML = ret;
The regex matches multiple occurrences (due to the g
modifier) of 1 or more (due to the +
quantifier) characters that are NOT:
\w
- ASCII letters, digits or _
а-яёА-ЯЁ
- Russian letters\u0561-\u0587
- Armenian capital letters\u0531-\u0556
- Armenian lowercase letters-
- a hyphen.See this Unicode reference on Armenian letter ranges used in the pattern.
Upvotes: 4