How to extract this number from a string in Javascript? [duplicate]

This question already has an answer here:

  • Why do regex constructors need to be double escaped?

    4 answers

I am trying to extract the number from the sample string, but it returns null, any idea why? Thanks,

var sample = 'sample 650-0011 (PP)'
var jreg = new RegExp("(\d{3}-\d{4}) (PP)$")

var rslt = sample.match(jreg)

All topic