当前位置:网站首页>正则表达式
正则表达式
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的字符
边栏推荐
猜你喜欢

Code merging of centralized version control tools

Esp8266---json---c function library provides string functions

ESP8266 STA_TCP_Server

Unity Line接入

MQTT协议------上

OJ question of sequence table

Web Service (04) -- Introduction and construction of lamp +discuz Forum

ESP8266 STA_ TCP_ Client

Esp8266 --- JSON data exchange format

ESP8266-----SNTP获取网络时间
随机推荐
7. Formula F1 champion
Remember that the scene rendered by rawimage is disordered once
Unity 使用NavMesh实现简易的摇杆功能
Shell(7)case语句
Network foundation of software test interview questions
软件测试面试题之xpath
十二、正则表达式
Dream journey
ESP8266 AP_ UDP_ Client
Linked list general OJ
ESP8266 AP_TCP_Client
5、 Conditional statement of shell
Software Foundation of software test interview questions
#快捷键介绍
域名分析和DNS的配置安装
Traversing binary trees in non recursive pre -, middle -, and post order
Surrounded area
Shell(12)正则表达式
Shell(13)三剑客
iptables防火墙(二)