I have a following regex expression in javascript
var reg = new RegExp("^[(]?[2-9]\d{2}[)]?[\-. :]?[2-9]\d{2}[\-. :]?\d{4}$");
return this.optional(element) || (reg.test(value));
in my code reg.test(value) return false even on correct values: for instance 222 222 2222 or 222-222-2222. All regex testers(especially this one, which calls the same methods) show that regex matches the expression. What can be the problem?