How I can passing quantifier as variable in this regexp str.match(/^(\-)?\d+( (\-)?\d+){3}$/)
AndrisP 193 Posting Pro in Training
Recommended Answers
Jump to PostYou can if you use something like this:
var q = "3"; var re = new RegExp("/^(\-)?\d+( (\-)?\d+){" + q + "}$"); if (re.test(str)) //...
All 4 Replies
pritaeas 2,211 ¯\_(ツ)_/¯ Moderator Featured Poster
AndrisP 193 Posting Pro in Training
pritaeas 2,211 ¯\_(ツ)_/¯ Moderator Featured Poster
AndrisP 193 Posting Pro in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.