wiki/运维/操作系统/Linux/笔记/18.正则表达式.md
2025-01-02 10:46:09 +08:00

23 lines
673 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 1、基本正则表达式
##### 1.1 字符匹配
- .:匹配任意单个字符
- []:匹配指定范围内的任意单个字符,示例[0-9]
- [^]:匹配指定范围外的人一个字符
##### 1.2 匹配次数
- *匹配前面的字符0次或任意次
- .*:匹配任意长度的任意字符
- \匹配前面的字符0次或者1次
- \+:匹配前面的字符至少一次
- \{n\}匹配前面的字符n次
- \{mn\}匹配前面的字符至少m次至多n次
- \n\匹配前面的字符至多n次
- \n\匹配前面的字符至少n次
##### 1.3 位置锚定
^:行首锚定
$:行尾锚定
^$:空行
##### 1.4 或者
\|