Javascript String parseEffectiveValue(defaultValue)

Description

Javascript String parseEffectiveValue(defaultValue)


String.prototype.parseEffectiveValue = function(defaultValue) {
    var val = this.replace(/[a-z:,\s\n]+/gi, '').match(/([0-9]+)(\[([0-9\-]+)\])?/);
    if (val === null) return [0,0];
    return  val[3] ? [Number(val[1]), Number(val[3])] : [Number(val[1]), Number(val[1])];
};



PreviousNext

Related