当前位置:网站首页>Regular expression: judge whether it conforms to USD format
Regular expression: judge whether it conforms to USD format
2022-07-26 08:47:00 【The tide does not fall】
Title Description :

Operation steps
The topic uses regular expressions to determine the string format , My other two previous articles Thousand digit separated number , Regular expressions
function isUSD(str) {
var reg = /^\$\d{1,3}(,\d{3})*(\.\d{2})?$/
return reg.test(str)
}
You can see that the code using regular expressions is so simple and efficient , Learning regular expressions well does provide a lot of convenience in daily work and study .
/^\$\d{1,3}(,\d{3})*(\.\d{2})?$/
^ First line match \ $ Ahead \ It's the escape character , Represents a match Dollar symbol $
\d{1-3} Express matching 1 to 3 A digital
() Is the grouping consistent with (,\d{3})* Express Comma followed by 3 Any number , * Represents a match 0 Or many times
(\.\d{2})? \. It means escaping the decimal point , The entire statement represents Decimal point followed by 2 Any number ,? Represents a match 0 or 1 Time
$ Indicates that the end of the line matches
边栏推荐
- MySQL 8.0 OCP 1z0-908 certification examination question bank 1
- Oracle 19C OCP 1z0-082 certification examination question bank (36-41)
- tcp 解决short write问题
- [abstract base class inheritance, DOM, event - learning summary]
- Oracle 19C OCP 1z0-083 question bank (1-6)
- Cve-2021-3156 duplicate of sudo heap overflow privilege raising vulnerability
- uni-app 简易商城制作
- 23.5 event listeners of application events and listeners
- Oracle 19C OCP 1z0-082 certification examination question bank (42-50)
- 基于C#实现的文件管理文件系统
猜你喜欢
![[freeswitch development practice] user defined module creation and use](/img/5f/3034577e3e2bc018d0f272359af502.png)
[freeswitch development practice] user defined module creation and use

Mysql8 dual master and dual slave +mycat2 read / write separation

Kotlin data type

Solve the problem of C # calling form controls across threads

基于Raft共识协议的KV数据库

What are the contents of Oracle OCP and MySQL OCP certification exams?

Excel find duplicate lines

Kotlin属性与字段

Kept dual machine hot standby

6、 Pinda general permission system__ pd-tools-log
随机推荐
基于C语言实现的人机交互软件
Alphabetic string
Kotlin variables and constants
Human computer interaction software based on C language
Arbitrum launched the anytrust chain to meet the diverse needs of ecological projects
Number of briquettes & Birthday Candles & building blocks
After MySQL 8 OCP (1z0-908), hand in your homework
Recurrence of SQL injection vulnerability in the foreground of a 60 terminal security management system
The effective condition of MySQL joint index and the invalid condition of index
TypeScript版Snowflake主键生成器
Automation and disconnection monitoring of video addition
Okaleido上线聚变Mining模式,OKA通证当下产出的唯一方式
SSH,NFS,FTP
File management file system based on C #
Deploy prometheus+grafana monitoring platform
Mysql8 one master one slave +mycat2 read write separation
Introduction to AWD attack and defense competition
P1825 [USACO11OPEN]Corn Maze S
[C language] programmer's basic skill method - "creation and destruction of function stack frames"
Hegong sky team vision training Day6 - traditional vision, image processing