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

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -