Skip to content

igsnow/regexp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 

Repository files navigation

正则表达式

基本语法

single char quantifiers(数量) position(位置)
\d 匹配数字 * 0个或者更多 ^一行的开头
\w 匹配word(数字、字母) + 1个或更多,至少1个 $一行的结尾
\W 匹配非word(数字、字母) ? 0个或1个,一个Optional \b 单词"结界"(word bounds)
\s 匹配white space(包括空格、tab等) {min,max}出现次数在一个范围内
\S 匹配非white space(包括空格、tab等) {n}匹配出现n次的
. 匹配任何,任何的字符

注意事项

 /\w/i    忽略大小写  
 /\w/g    全局匹配   
 re.test(str)   =>  boolean  
 str.match(re)  =>  array  

字符分类

  分类符[]
     [abc] => a 或 b 或 c
     [-.]  => 符号- 或 .
     (a|b) => 表示a 或 b
     注意: 1.在[]里面表示符号,在外面表示通配符,特殊字符在外面都需要转义,如\.转义;
           2.[a-z]中'-'不是第一个字符,而是表示a到z;
           3.[^ab]中'^'不是表示一行的开头,而表示除了a或者b都可以。)      

About

Regexp Study 正则表达式

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published