一、正则非贪婪模式怎样表示
要想开启正则表达式非贪婪模式,需要在量词后面添加“?”。在Java、Python等编程语言中,可以在量词后面添加“?”,例如:
import re
# 将贪婪模式转为非贪婪模式
str = 'aa
cc
ee'
str_list = re.findall(r"<.*?>", str)
print(str_list) # ['', '
']
import re
# 将贪婪模式转为非贪婪模式
str = 'aa
cc
ee'
str_list = re.findall(r"<.*?>", str)
print(str_list) # ['', '
']
2023-05-18
2023-05-19
2022-11-16
2023-05-19
2022-11-30
2022-11-12
2023-05-11
2023-05-13
2022-11-30
2023-05-20
2022-11-15
2022-11-09
2023-05-13
2023-01-06
2023-01-08
2022-12-01
2022-11-11
2023-05-13
2022-11-08
2022-11-12