0

I'm trying to use regex in javascript to match something, but it's not working properly. What am I doing wrong?

var skipForNow = "one(1),two(2)"
var one = "one";
var tempArray = skipForNow.match(new RegExp(one+"([1-9]+)", 'g'));

document.write(tempArray[0]);

Expected Output:

one(1)

Actual Output:

JavaScript error: Uncaught TypeError: Cannot read property '0' of null
lucascaro
  • 16,550
  • 4
  • 37
  • 47
frosty
  • 2,559
  • 8
  • 37
  • 73

0 Answers0