float-regex
regular expression for real floating point values in javascript notation:
moduleexports = /[-+]??/;
does not match:
- +/- Infinity
- NaN
example
anchor a string:
var anchor = RegExp'^' + source + '$';console; // trueconsole; // false
capture floats:
var freg = source;var capture = RegExp'\\b(' + freg + ')\\b' 'g';var str = '1.2 555 beep boop 4.2.1.5 66.2e99 22.54e23 qrs2';console;
which prints:
[ '1.2', '555', '4.2', '.1', '.5', '66.2e99', '22.54e23' ]
install
With npm do:
npm install float-regex
license
MIT