First number located in the string - Node.js String

Node.js examples for String:Parse

Description

First number located in the string

Demo Code

String.prototype.firstNumber = function () {
    var m;//from  w  ww  .j a v a  2  s  . c om
    if ((m = this.match(/\d+/)) !== null){
        return m[0];
    }
};

Related Tutorials