Answer the question
In order to leave comments, you need to log in
How to check for matches in an array with regular expressions?
Hello.
I have never encountered checking for a match of characters in an array.
For example, there is an array and a string:
var arr = ['@','.ru','.com'],
string = '[email protected]';
Answer the question
In order to leave comments, you need to log in
var fragments = ['@','.ru','.com'];
var str = '[email protected]';
if (fragments.some(fragment => str.includes(fragment)) ) {
// ...
}
/@|\.ru|\.com/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question