Is string a digit via regex - Node.js Regular expression

Node.js examples for Regular expression:Match

Description

Is string a digit via regex

Demo Code


function isDigit(s)
{
  var patrn=/^[0-9]{1,20}$/;
  if (!patrn.exec(s)){
    return false ;
  }/*from ww  w . j  a v  a 2s  .  c o  m*/
  return true ;
}

Related Tutorials