【正则表达式】正则表达式中的修饰符 -- img
时间 2020-07-12
标签
正则表达式
正则
表达式
修饰
img
修饰符
符号 |
做用 |
示例 |
示例含义 |
匹配结果 |
i |
忽略大小写(ignore) |
“Hello \nRegular Expression”.match(/E/i) |
匹配字母 E 忽略大小写(默认匹配到第一个知足条件就直接返回) |
e |
m |
多行匹配(multiline) |
“Hello \nRegular Expression”.match(/e/m) |
匹配字母 e, 多行匹配 |
e |
g |
全局匹配(global) |
“Hello \nRegular Expression”.match(/e/g) |
匹配字母 e, 全局匹配(返回全部知足条件的结果) |
e,e,e |
|
|
“Hello \nRegular Expression”.match(/e/im) |
忽略大小写的多行匹配 |
e |
|
|
“Hello \nRegular Expression”.match(/e/ig) |
忽略大小写的全局匹配 |
e,e,E,e |
|
|
“Hello \nRegular Expression”.match(/e/mg) |
全局多行匹配 |
e,e,e |
|
|
“Hello \nRegularExpression”.match(/e/img) |
忽略大小写的全局多行匹配 |
e,e,E,e |
|
|
“ello \negularExpression”.match(/^e/g) |
全局匹配位于开始位置的字母 e |
e |
|
|
“ello \negularExpression”.match(/^e/gm) |
全局多行匹配位于开始位置的字母 e |
e,e |