Javascript Regexp Match Test
var my_string = '2010-09-01';
var regExp = new RegExp('^[0-9]{4}\-[0-9]{2}\-[0-9]{2}$', 'gim');
if(my_string.match(regExp)) {
alert('String matches expression');
} else {
alert('String doesn't match expression');
}
var regExp = new RegExp('^[0-9]{4}\-[0-9]{2}\-[0-9]{2}$', 'gim');
if(my_string.match(regExp)) {
alert('String matches expression');
} else {
alert('String doesn't match expression');
}
No comments:
Post a Comment