I am setting up this example Perl snippet to validate for months in a date:
Some scenarios I want to accept are:
MM M
#!/usr/bin/perl use str
"^(1[012]|0?[1-9])$" would be better because regular expression is assessed first one first. Let's say you want to match '12' and you write "^(0?[1-9]|1[012])$", then '1' will be picked because 0?[1-9] is taken first.
"^(1[012]|0?[1-9])$"
"^(0?[1-9]|1[012])$"
0?[1-9]