scarhand Posted September 16, 2010 Share Posted September 16, 2010 need to test to see if "field" is formatted as NN-NN-NN where N = a digit heres my code: /\d{2}-\d{2}\d{2}/.test(field) == false doesn't seem to work. Link to comment https://forums.phpfreaks.com/topic/213590-help-with-simple-nn-nn-nn-regex/ Share on other sites More sharing options...
scarhand Posted September 16, 2010 Author Share Posted September 16, 2010 got it. /^(\d){2}-(\d){2}-(\d){2}$/ Link to comment https://forums.phpfreaks.com/topic/213590-help-with-simple-nn-nn-nn-regex/#findComment-1111740 Share on other sites More sharing options...
Psycho Posted September 16, 2010 Share Posted September 16, 2010 Since it is only two digits grouped together I would just do the following for clarity /^\d\d-\d\d-\d\d$/ Link to comment https://forums.phpfreaks.com/topic/213590-help-with-simple-nn-nn-nn-regex/#findComment-1111766 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.