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
  • 13,530
  • 2
  • 35
  • 45
frosty
  • 2,402
  • 7
  • 29
  • 65

0 Answers0