var str = "122,22"; var re = new RegExp("^-?(?:\d+|\d{1,3}(?:.\d{3})+)(?:\,\d+)?$", ""); var myArray = re.test(str);