当前位置:网站首页>Regular check matches positive integer or decimal limit between [0-100] and [0-1000]
Regular check matches positive integer or decimal limit between [0-100] and [0-1000]
2022-06-11 21:05:00 【Hertz /herzz】
Matching positive integer
[0-100] Not included 0 and 100
const reg = /^([1-9][0-9]{0,1}|99)$/
if (reg.test(value) === false) {
console.log(` Check by ---`)
}
[0-100] contain 0 and 100
const reg = /^([0-9][0-9]{0,1}|100)$/ // Pay attention to the details here
if (reg.test(value) === false) {
console.log(` Check by ---`)
}
[0-1000] Not included 0 and 1000
const reg = /^([1-9][0-9]{0,2}|999)$/
if (reg.test(value) === false) {
console.log(` Check by ---`)
}
[0-1000] contain 0 and 1000
const reg = /^([0-9][0-9]{0,2}|1000)$/
if (reg.test(value) === false) {
console.log(` Check by ---`)
}
Match a positive number + Decimal limit
[0-1000] Not included 0 and 1000, Keep one decimal place
const reg = /^([1-9]\d{0,2}|999.9)(\.\d{1})?$/
if (reg.test(value) === false) {
console.log(` Check by ---`)
}
[0-1000] contain 0 and 1000, After decimal point 1 position
const reg = /^([0-9]\d{0,2}|1000)(\.\d{1})?$/
if (reg.test(value) === false) {
console.log(` Check by ---`)
}
[0-10000] Not included 0 and 10000, After decimal point 3 position
const reg = /^([1-9][0-9]{0,3}(\.\d{1,3})?|9999.999)$/
if (reg.test(value) === false) {
console.log(` Check by ---`)
}
[0-10000] contain 0 and 10000, After decimal point 3 position
const reg = /^([0-9][0-9]{0,3}(\.\d{1,3})?|10000)$/
if (reg.test(value) === false) {
console.log(` Check by ---`)
}
notes : Close test effectively , But including 0 Under the circumstances 01、02、03… Will pass the verification , There are quick ways to come up with .
边栏推荐
- 周刊02|不瞒你说,我其实是MIT的学生
- JS monitor scrolling touch bottom load more_ Browser scrolls to the bottom to load more
- The e-sports Internet cafe uses a 2.5G network card to experience the feeling of flying!
- Figure guessing game
- Serval and Rooted Tree(CF1153D)-DP
- Black circle display implementation
- Wechat applet | rotation chart
- Windows icon display exception resolution. The desktop icon is abnormal, the start menu icon is abnormal, and the taskbar icon is abnormal. Icon cache location.
- Lr-link Lianrui makes its debut at the digital Expo with new products - helping the construction of new infrastructure data center
- ubantu1804 两个opencv版本共存
猜你喜欢

Compilation process of program

Chinese text classification based on CNN

周刊02|不瞒你说,我其实是MIT的学生

Black circle display implementation

新品发布:LR-LINK联瑞推出首款25G OCP 3.0 网卡

Live broadcast with practice | 30 minutes to build WordPress website with Alibaba cloud container service and container network file system

Wechat applet | rotation chart
![[data visualization] use Apache superset to visualize Clickhouse data](/img/4b/a73c2eb810f1d2b492e950afb2d0bc.png)
[data visualization] use Apache superset to visualize Clickhouse data

Object storage of CEPH distributed storage

重投农业,加码技术服务,拼多多底盘进一步夯实
随机推荐
go语言的goto语句
[game theory complete information static game] strategic game
从概率论基础出发推导卡尔曼滤波
[file upload vulnerability 04] server side mime detection and bypass experiment (based on upload-labs-2 shooting range)
Release of version 5.6 of rainbow, add multiple installation methods, and optimize the topology operation experience
Application scenario: wide application of Poe network card in NDI technology for live broadcast program production
Pyqt5 technical part - cause of the problem that setting the top of the window does not take effect. Setwindowflags() does not take effect after setting the parameters. Solution
How to Load Data from CSV (Data Preparation Part)
JMeter load test finds the maximum number of concurrent users (including step analysis)
技术交流|网络安全设备为什么要用Bypass功能
Goland中在文件模板中为go文件添加个人声明
Solution to unlimited restart of desktop and file explorer
Systematically study the recommendation system from a global perspective to improve competitiveness in actual combat (Chapter 8)
Simple classification example of brain cell membrane equivalent neural network
[nk] deleted number of 100 C Xiaohong in Niuke practice match
为什么100G网络传输要使用iWARP、RoCE v2、NVMe-oF等协议
Explanation of each column output by explain statement
Gestionnaire de paquets d'Unit é Starting Server Stuck
How to Load Data from CSV (Data Preparation Part)
Wechat applet | rotation chart