1.什么是正则表达式?
正则表达式是用于匹配字符串中字符组合的模式。
在javascript中,正则表达式也是对象,可以通过 RegEXP 和 String 的方法使用这些模式。
2.创建一个正则表达式
两种方式:静态正则表达式/动态正则表达式
静态 var re = /ab + c/ // /ab+c/
动态 var re = new RegExp("ab+c") // /ab+c/
3.编写模式
简单模式/特殊字符
4.常用内容
【其他教程推荐】
1. 正则表达式30分钟入门教程 作者: deerchao https://deerchao.cn/tutorials/regex/regex.htm
2. Regex tutorial — A quick cheatsheet by examples (英文) 作者: Jonny Fox https://medium.com/factory-mind/regex-tutorial-a-simple-cheatsheet-by-examples-649dc1c3f285
3. Regular Expressions Tutorial (英文) https://www.regular-expressions.info/tutorial.html
要解决的问题
1.不能0开头,小数点后只能输入两位
练习 地址
regex101: build, test, and debug regex