Answer the question
In order to leave comments, you need to log in
How to check the value of a regular expression that came from the server?
Good afternoon!
How to check the value of a regular expression that came from the server? As I understand it, you need to convert the string to a regular expression.
I tried to check the expression through the test method, but I get the error Uncaught SyntaxError: Unexpected token ^ , I understand that I need to escape, but the regular expression does not work.Pattern:"^\d{5}$"
var re = /^\d{5}$/;
if (re.test( "4" ) ) {
alert("Данная строка соответсвует заявленому патерну");
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question