0.1.1 • Published 6 years ago
@regexp-extra/float v0.1.1
RegExp for matching floating-point number.
const FLOAT = require('@regexp-extra/float');
// -> regular expression (global)
FLOAT.test('cake');
// false
FLOAT.test('12.31');
// true
var str = '1 canteen: 1000kg = Infinity mangoes';
str.match(FLOAT);
// [ '1', '1000', 'Infinity' ]
new RegExp(FLOAT).exec(str);
// [ '1',
// '', (sign)
// '1', (mantissa)
// undefined, (exponent)
// index: 0,
// input: '1 canteen: 1000kg = 0x12C mangoes',
// groups: undefined ]
credits: taken idea from substack/float-regex.