0

Using this regex /var userId = (\d+)/, I can find the id of the user. Except it returns "var userId = 117051" instead of just 117051. I looked around in regexr but I'm not very good with regex. Is there a way to only get the id?

Hugo
  • 349
  • 3
  • 6
  • 23

1 Answers1

2
string = "some string containing var userId = 117051";
var foundId = string.match(/var userId = (\d+)/)[1];
console.log(foundId); // "117051"
DenverCoder1
  • 2,253
  • 1
  • 10
  • 23