I have this regex.
MMM D[,] YYYY /^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\ (\d{2})\, (\d{4})$/
How can I do this [,] is optional?
MMM D, YYYY MMM D YYYY
just do ,? , which makes the comma optional.
,?
Did not check the rest of the expression, but placing ? after the decimal point, let's say it is 0 or 1 time. If you want to allow multiple commas, you must use * , from 0 to infinity.
?
*
The question mark after the character makes it optional in the regular expression.