jaytea commented on a Page, 2012 countdown  -  Sep 29, 2011

i don't see where 2024 came from, but imo the question of whether or not it would be suitable to perform the range check in the regular expression depends upon the extent to which that value is tied to the script. we wouldn't want to hardcode regex if 2024 is arbitrary and susceptible to change. after all, magic numbers pale in comparison to the idea of magic subexpressions ;P

if 2024 is fundamental to the script's design, and the script wouldn't make sense with any other value, then you can safely include it in your regular expression if you prefer. otherwise, ensure you're dealing with a series of digits (\d+), since isnum does not precisely validate the composition of the number, and check the range with mSL. i would say that regular expressions should be used to validate the structure of the string, and your programming language to validate its meaning.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.