81 lines
1.7 KiB
Plaintext
81 lines
1.7 KiB
Plaintext
|
|
||
|
{{alias}}( [options] )
|
||
|
Returns a regular expression to match a decimal number.
|
||
|
|
||
|
A leading digit is not required.
|
||
|
|
||
|
A decimal point and at least one trailing digit is required.
|
||
|
|
||
|
Parameters
|
||
|
----------
|
||
|
options: Object (optional)
|
||
|
Options.
|
||
|
|
||
|
options.flags: string (optional)
|
||
|
Regular expression flags. Default: ''.
|
||
|
|
||
|
options.capture: boolean (optional)
|
||
|
Boolean indicating whether to create a capture group for the match.
|
||
|
Default: false.
|
||
|
|
||
|
Returns
|
||
|
-------
|
||
|
re: RegExp
|
||
|
Regular expression.
|
||
|
|
||
|
Examples
|
||
|
--------
|
||
|
> var RE = {{alias}}();
|
||
|
> var bool = RE.test( '1.234' )
|
||
|
true
|
||
|
> bool = RE.test( '-1.234' )
|
||
|
true
|
||
|
> bool = RE.test( '0.0' )
|
||
|
true
|
||
|
> bool = RE.test( '.0' )
|
||
|
true
|
||
|
> bool = RE.test( '0' )
|
||
|
false
|
||
|
> bool = RE.test( 'beep' )
|
||
|
false
|
||
|
|
||
|
// Create a RegExp to capture all decimal numbers:
|
||
|
> var re = {{alias}}({ 'flags': 'g' });
|
||
|
> var str = '1.234 5.6, 7.8';
|
||
|
> var out = str.match( re )
|
||
|
[ '1.234', '5.6', '7.8' ]
|
||
|
|
||
|
|
||
|
{{alias}}.REGEXP
|
||
|
Regular expression to match a decimal number.
|
||
|
|
||
|
A leading digit is not required.
|
||
|
|
||
|
A decimal point and at least one trailing digit is required.
|
||
|
|
||
|
Examples
|
||
|
--------
|
||
|
> var RE = {{alias}}.REGEXP;
|
||
|
> var bool = RE.test( '1.234' )
|
||
|
true
|
||
|
> bool = RE.test( '-1.234' )
|
||
|
true
|
||
|
|
||
|
|
||
|
{{alias}}.REGEXP_CAPTURE
|
||
|
Regular expression to capture a decimal number.
|
||
|
|
||
|
A leading digit is not required.
|
||
|
|
||
|
A decimal point and at least one trailing digit is required.
|
||
|
|
||
|
Examples
|
||
|
--------
|
||
|
> var RE = {{alias}}.REGEXP_CAPTURE;
|
||
|
> var str = '1.02';
|
||
|
> var out = {{alias:@stdlib/string/replace}}( str, RE, '$1 x $1' )
|
||
|
'1.02 x 1.02'
|
||
|
|
||
|
See Also
|
||
|
--------
|