Build a dynamic regex with a variable

  • by

I needed to build a dynamic regex, which consists of a variable.

var decimal_separator = ".";
var regex = new RegExp("[0-9]|\\" + decimal_separator);