JS regular matching of integers and decimals

Time:2021-4-17
let _ Check = / ^ ([1-9] [D] {0,6} 0) (\. [D] {1,2}) $/; // limit the number of digits before and after the decimal point
let _ Check1 = / ^ ([1-9] [D] * | 0) (\. [D] +)? $/; // do not limit the number of digits before and after the decimal point
_check.test('0.10') // true
_check.test('000.10') // false
_check.test('0') // true
_check.test('9') // true
_check.test('9.9') // true
_check.test('9.90') // true
_check.test('9.900') // false
_check.test('90')  // true
_check.test('090')  // false
_check.test('9..90')  // false
_check.test('9.9.0') // false
_check.test('009') // false
_check.test('0009.90') //false
_check.test('9000000')  // false

original text

Recommended Today

Ffmpeg plays RTSP / webcam stream

This article will introduce how ffmpeg plays RTSP / webcam / file streams. The process is as follows: RTSP/Webcam/File > FFmpeg open and decode to BGR/YUV > OpenCV/OpenGL display code:https://github.com/ikuokuo/rt…, sub module RTSP local player Ffmpeg preparation git clone https://github.com/ikuokuo/rtsp-wasm-player.git cd rtsp-wasm-player export MY_ROOT=`pwd` # ffmpeg: https://ffmpeg.org/ git clone –depth 1 -b n4.4 https://git.ffmpeg.org/ffmpeg.git $MY_ROOT/3rdparty/source/ffmpeg […]