Hello campers
I am trying to check where an input is in natural time format i.e December 20, 2016
var regx= new RegExp('/^[a-zA-Z]+\s?\d{2},\s?\d+$/gi');
regx.test('December 16, 2015')
my test result is coming false . What wront did I do?
Hello campers
I am trying to check where an input is in natural time format i.e December 20, 2016
var regx= new RegExp('/^[a-zA-Z]+\s?\d{2},\s?\d+$/gi');
regx.test('December 16, 2015')
my test result is coming false . What wront did I do?
@Sifatul,
running your regular expression yields a match
I am assuming you are using Javascript and the error you are having is that you do not need single quotes surrounding your regular expression.
Meaning,
var regx= new RegExp(/^[a-zA-Z]+\s?\d{2},\s?\d+$/gi);
regx.test('December 16, 2015') <-- returns true
I would argue that you can limit the last part of your regular expression to 4 digits instead of +.
Hope that helps
Thank you for checking through my code.
Those are 4 digits are for this just few millenniums and after that if my code does not work I don’t care