当前位置:网站首页>正则表达式
正则表达式
2022-07-26 22:44:00 【奇怪的蘑菇】
- 正则表达式常见元字符
- 特殊字符(注意:支持的工具grep egrep sed awk)
- \:转义符,将特殊字符进行转义,
- ^:匹配行首,^xxxx以xxx开头
- $:匹配行尾,和上面差不多
- .:匹配除换行符\n\r以为的任意单个字符
- [list]:匹配list列表中的一个字符
- [^list]:取反咯,匹配任意部在列表中的字符
- *:匹配前面子表达式0次或者多次
- \{n\} :匹配前面的子表达式n次,例:go{2}d、'[O-9]{2}'匹配两位数字
- \{n,\}:匹配前面的子表达式不少于n次,例: go\{2,\}d、' [0-9]\{2,\}'匹配两位及两位以上数宁
- \{n,m\}﹔匹配前面的子表达式n到m次,例: go\{2,3\)d、'[0-9]\{2,3\}'匹配两位到三位数字
- 特殊字符(注意:支持的工具grep egrep sed awk)
- 扩展正则表达式
- 字符:(注意:支持工具egrep、awk)
- +:重复一个或多个前面一个以上的前一个字符
- ?:匹配0个或多次前一个字符
- |:类似or,egrep -n 'a|b|c' test.txt”命令即可查询"a"或者"b"或者"c"字符串
- ():查找组字符,将其看作一个整体
- ()+:匹配多给重复的组
- 字符:(注意:支持工具egrep、awk)
- 实例:
- 查找包含i/o的字符
- grep -n 'sh[io]rt' test.txt
- 反向过滤包含w的字符
- grep -n '[^w]oo' test.txt
- 连续匹配指定次数
- grep -n 'o\{2\}' test.txt
- 匹配完整数字
- grep -n '[0-9][0-9]*' test.txt
- 查找包含i/o的字符
边栏推荐
猜你喜欢
随机推荐
ESP8266 STA_Server
五、Shell之条件语句
Remember that the scene rendered by rawimage is disordered once
The MySQL character set is set to UTF-8, but the console still has the problem of Chinese garbled code
8、 Definition of array
7、 Loop statement
1101: numbers in reverse order (function topic)
Jenkins -- Basic -- 5.1 -- system configuration -- plug-in management
Jenkins -- Basic -- 03 -- post installation setup wizard
Web服务(07)——LNMP一键部署
Adding, deleting, checking and modifying dynamic sequence table with C language
[ctf real question] 2018 WANGDING cup web unfinish
MQTT协议------上
Code merging of centralized version control tools
Lamp+discuz Forum
Scoring system based on 485 bus
Unity引擎基础
5、 Conditional statement of shell
ESP8266---JSON数据交换格式
LAMP+DISCUZ论坛
![[unity] unity interface scene view [1]](/img/5a/c34ff09ef1ddba4b65c7873775c251.png)



![[SQL injection] joint query](/img/82/37008a1ecb4bb37bea42443dbb9be6.png)




