javascript - Regexp: Check for digits and whitespaces -


i using following regexp make sure string contains 5 digits. works perfect, however, need allow whitespaces: 123 45 , 12345 need pass test.

string.match(/^\d{5}$/g); 

thanks

you remove whitespace , try match rest:

string.replace(/\s/g, "").match(/^\d{5}$/g) 

Comments

Popular posts from this blog

forms - Secure PHP File Upload Script -

silverlight - SL4 - TextTrimming in DataGridRowGroupHeader -

c# - Regex Problems, extracting data to groups -