1
0

init
Some checks failed
Build / build (push) Has been cancelled

This commit is contained in:
yuudi
2025-08-10 11:04:12 +00:00
commit 728a3db957
20 changed files with 527 additions and 0 deletions

39
content/util/regex.md Normal file
View File

@@ -0,0 +1,39 @@
+++
date = '2025-08-10T12:37:16Z'
title = '正则'
+++
## 原子组
不回溯
```regex
(?>...)
```
## 占有量词
不回溯
```regex
.*+
.++
.?+
```
## 详细模式Verbose Mode / Free-Spacing Mode
```python
regex_verbose = r"""
^ # 匹配字符串开头
(\d{4}) # 捕获四位数的年份
- # 匹配连字符
(\d{2}) # 捕获两位数的月份
- # 匹配连字符
(\d{2}) # 捕获两位数的日期
$ # 匹配字符串结尾
"""
date_string = "2023-10-26"
match = re.match(regex_verbose, date_string, re.VERBOSE)
```