repl.txt (1766B)
1 2 {{alias}}( [options] ) 3 Returns a regular expression to match a decimal number. 4 5 A leading digit is not required. 6 7 A decimal point and at least one trailing digit is required. 8 9 Parameters 10 ---------- 11 options: Object (optional) 12 Options. 13 14 options.flags: string (optional) 15 Regular expression flags. Default: ''. 16 17 options.capture: boolean (optional) 18 Boolean indicating whether to create a capture group for the match. 19 Default: false. 20 21 Returns 22 ------- 23 re: RegExp 24 Regular expression. 25 26 Examples 27 -------- 28 > var RE = {{alias}}(); 29 > var bool = RE.test( '1.234' ) 30 true 31 > bool = RE.test( '-1.234' ) 32 true 33 > bool = RE.test( '0.0' ) 34 true 35 > bool = RE.test( '.0' ) 36 true 37 > bool = RE.test( '0' ) 38 false 39 > bool = RE.test( 'beep' ) 40 false 41 42 // Create a RegExp to capture all decimal numbers: 43 > var re = {{alias}}({ 'flags': 'g' }); 44 > var str = '1.234 5.6, 7.8'; 45 > var out = str.match( re ) 46 [ '1.234', '5.6', '7.8' ] 47 48 49 {{alias}}.REGEXP 50 Regular expression to match a decimal number. 51 52 A leading digit is not required. 53 54 A decimal point and at least one trailing digit is required. 55 56 Examples 57 -------- 58 > var RE = {{alias}}.REGEXP; 59 > var bool = RE.test( '1.234' ) 60 true 61 > bool = RE.test( '-1.234' ) 62 true 63 64 65 {{alias}}.REGEXP_CAPTURE 66 Regular expression to capture a decimal number. 67 68 A leading digit is not required. 69 70 A decimal point and at least one trailing digit is required. 71 72 Examples 73 -------- 74 > var RE = {{alias}}.REGEXP_CAPTURE; 75 > var str = '1.02'; 76 > var out = {{alias:@stdlib/string/replace}}( str, RE, '$1 x $1' ) 77 '1.02 x 1.02' 78 79 See Also 80 --------