diff --git a/text1.py b/text1.py
new file mode 100644
index 0000000..8672b41
--- /dev/null
+++ b/text1.py
@@ -0,0 +1,13 @@
+import re
+text = '''
+2024-03-15 天气:晴 温度:15-25°C
+2024-03-16 天气:多云 温度:12-20°C
+2024-03-17 天气:小雨 温度:10-18°C
+'''
+
+pattern = r'(\d{4}-\d{2}-\d{2})\s*天气:([^ ]+)\s*温度:(\d+)-(\d+)°C'
+matches = re.findall(pattern, text)
+
+for match in matches:
+ date, weather, low, high = match
+ print(f'{date}: {weather}, {low}°C-{high}°C')
\ No newline at end of file
diff --git a/text2.py b/text2.py
new file mode 100644
index 0000000..0c38497
--- /dev/null
+++ b/text2.py
@@ -0,0 +1,33 @@
+import re
+
+html = '''
+
+
《流浪地球》
+ (2024)
+ 8.5
+ 导演:郭帆
+
+
+
《你好,李焕英》
+ (2024)
+ 7.9
+ 导演:贾玲
+
+'''
+
+# 编写正则表达式,提取所有电影信息
+# pattern = r'你的正则表达式'
+
+# 提示:可以用多个正则分别提取,或者用一个复杂的正则提取所有
+name_pattern = r'《([^》]+)》
'
+year_pattern = r'\((\d{4})\)'
+rating_pattern = r'([^<]+)'
+director_pattern = r'导演:([^<]+)'
+
+names = re.findall(name_pattern, html)
+years = re.findall(year_pattern, html)
+ratings = re.findall(rating_pattern, html)
+directors = re.findall(director_pattern, html)
+
+for i in range(len(names)):
+ print(f"{names[i]} | {years[i]} | 评分:{ratings[i]} | {directors[i]}")
\ No newline at end of file
diff --git a/text3.py b/text3.py
new file mode 100644
index 0000000..2158475
--- /dev/null
+++ b/text3.py
@@ -0,0 +1,15 @@
+import re
+
+log = '''
+192.168.1.100 - - [15/Mar/2024:10:15:30 +0800] "GET /index.html HTTP/1.1" 200 1234
+10.0.0.50 - - [15/Mar/2024:10:15:31 +0800] "POST /api/login HTTP/1.1" 200 256
+192.168.1.101 - - [15/Mar/2024:10:15:32 +0800] "GET /notfound.html HTTP/1.1" 404 512
+172.16.0.200 - - [15/Mar/2024:10:15:33 +0800] "GET /images/logo.png HTTP/1.1" 200 4096
+'''
+
+# 提取 IP、时间和状态码
+pattern = r'(\d+\.\d+\.\d+\.\d+).*?\[([^\]]+)\].*?" (\d{3}) \d+'
+
+for match in re.finditer(pattern, log):
+ ip, time, status = match.groups()
+ print(f'IP: {ip:15} | 时间: {time:25} | 状态: {status}')
\ No newline at end of file
diff --git a/text4.py b/text4.py
new file mode 100644
index 0000000..e97cb05
--- /dev/null
+++ b/text4.py
@@ -0,0 +1,18 @@
+import re
+
+phone_book = '''
+张三:138-1234-5678
+李四:139-5678-1234
+王五:138-0000-1111
+'''
+
+# 脱敏:将 138-****-5678 格式输出
+# 提示:使用分组和 re.sub
+
+pattern = r'(\d{3})-(\d{4})-(\d{4})'
+
+def mask_phone(match):
+ return f'{match.group(1)}-****-{match.group(3)}'
+
+masked = re.sub(pattern, mask_phone, phone_book)
+print(masked)
\ No newline at end of file