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
  • 221
  • 1
  • 3
  • 19

1 Answers1

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