-6

My string is:'input type="hidden" value="5999" id="productPrice"'

I want to extract value from this string. Please help me to write regex for this.

chandni
  • 159
  • 1
  • 7

1 Answers1

1
var string = '<input type="hidden" value="5999" id="productPrice">';

var regex = /<input type="hidden" value="([^"]+)" id="productPrice"/gi;
var price = regex.exec(string);

console.log(price[1]);

price[1];
chandni
  • 159
  • 1
  • 7