当前位置:网站首页>正则表达式:判断是否符合USD格式
正则表达式:判断是否符合USD格式
2022-07-26 08:39:00 【潮汐未见潮落】
题目描述:

操作步骤
function isUSD(str) {
var reg = /^\$\d{1,3}(,\d{3})*(\.\d{2})?$/
return reg.test(str)
}
可以看到使用正则表达式的代码就是这么简单高效,学好了正则表达式的确在平时的工作学习上提供特别多的便利。
/^\$\d{1,3}(,\d{3})*(\.\d{2})?$/
^ 行首匹配 \ $ 前面的 \ 是转义字符,表示匹配 美元符号 $
\d{1-3} 表示 匹配 1至3 个数字
() 是分组符合 (,\d{3})* 表示 逗号后面带3个任意数字 , * 表示匹配 0或者多次
(\.\d{2})? \. 表示对小数点进行转义 ,整个语句表示 小数点后面带2个任意数字,?表示匹配 0或 1次
$ 表示行尾匹配
边栏推荐
- Memory management - dynamic partition allocation simulation
- In the first year of L2, the upgrade of arbitrum nitro brought a more compatible and efficient development experience
- Oracle 19C OCP 1z0-082 certification examination question bank (42-50)
- The second lesson is the construction of development environment
- Uninstallation of dual systems
- 基于C语言设计的换乘指南打印系统
- import error: ‘Icon‘ is not exported from ‘antd‘. Import icon error
- Logic of data warehouse zipper table
- Mysql8 one master one slave +mycat2 read write separation
- The data read by Flink Oracle CDC is always null. Do you know
猜你喜欢

23.6 23.7 web environment web environment variable reading

Write common API tools swagger and redoc
![[freeswitch development practice] use SIP client Yate to connect freeswitch for VoIP calls](/img/8b/d5792a00fc5798d3d960f1f1b1088e.png)
[freeswitch development practice] use SIP client Yate to connect freeswitch for VoIP calls

In the first year of L2, the upgrade of arbitrum nitro brought a more compatible and efficient development experience

Foundry tutorial: writing scalable smart contracts in various ways (Part 1)

Mysql/mariadb (Galera multi master mode) cluster construction

Kotlin program control

利用模m的原根存在性判断以及求解
![[time complexity, space complexity]](/img/f2/f82c7e0a6ab9f893023c2ddbac3431.png)
[time complexity, space complexity]

基于C语言实现的人机交互软件
随机推荐
[GUI] GUI programming; AWT package (interface properties, layout management, event monitoring)
[untitled]
2022年收益率最高的理财产品是哪个?
Install HR schema, example, and Scott schema on Oracle and MySQL
Using the primitive root of module m to judge and solve
What are the contents of Oracle OCP and MySQL OCP certification exams?
Flutter WebView three fingers rush or freeze the screen
Automation and disconnection monitoring of video addition
Fluent custom popupmenubutton
Lesson 3: gcc compiler
Huffman transformation software based on C language
22-07-14 personal training match 2 competition experience
Flutter compilation fails
Error handling response: Error: Syntax error, unrecognized expression: .c-container /deep/ .c-contai
JS tool function Encyclopedia
Flutter text is left aligned with no blank space in the middle
[time complexity, space complexity]
基于C语言的内存管理-动态分区分配方式模拟
General file upload vulnerability getshell of a digital campus system (penetration test -0day)
[recommended collection] summary of MySQL 30000 word essence - partitions, tables, databases and master-slave replication (V)