Home  >  Article  >  Web Front-end  >  javascript学习笔记(十一) 正则表达式介绍_基础知识

javascript学习笔记(十一) 正则表达式介绍_基础知识

WBOY
WBOYOriginal
2016-05-16 17:52:37891browse

1.修饰符
. 任意一个字符
* 匹配*前面0个或多个字符
+ 匹配+前面一个或多个字符
? 匹配?前面0个或1个字符
^ 以^后面的字符为前导
$ 以$前面的字符结尾
[] 匹配[]内的一个字符
() 分组,可以用\1 \2提取
[^] 匹配^后的以外的字符
{n} {n}前的字符有n个,n为正数
{n,} {n,}前的字符至少有n个,n为正数
{n,m} {n,m}前的字符有n~m个,n,m为正数

2.字符
\d 一个数字
\D 一个非数字
\w 一个字母或数字
\W 一个非字母和非数字
\s 一个空白字符
\S 一个非空白字符
\b 单词边界
\B 非单词边界

3.非贪婪匹配
+? *? ??

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn