Home javascript Using JS variables in Match

Using JS variables in Match

Author

Date

Category

How to insert correctly variables phone and phone_digs in Match so that it is like this:

s.match ('/' '+ Phone +' [0-9] {5} '+ phone_digs +' / g ')

This way, unfortunately, does not work.


Answer 1, Authority 100%

Create a new site Regexp

var pattern = new regExp (Phone + '[0-9] {5}' + Phone_Digs, G);
Console.log (S.Match (Pattern));

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions