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