I have this code:
var regExp=new RegExp("(\/|-|.)+","g");
var t1=regExp.test(new Date());
alert(t1);//result true
var t2=regExp.test("19/03/1986");
alert(t1);//result true
why, first alert, return true value? There is not any charatter defined into regex pattern...
Thanks

.means any character. Also, you should learn about char class instead of using alternation groups.should be\.gmodifier should be removed if you only use the regex withRegExp#test. Thenew Date()is passed to the regex as"2016-10-07T08:13:59.703Z"string that your regex matches entirely (since it is equal to.+), that is why the secondtestalso succeeds."(/|-)+"or"(/|-|\\.)+"as there is a-inside the input. But you'd better usevar regExp= /[-\/.]/;here.