brisonus_app_eq/ERNCTuningTool/test/test_re.py

14 lines
216 B
Python
Raw Permalink Normal View History

2025-02-18 22:05:52 +08:00
import re
# 输入字符串
input_str = "{tachofAmp0[0]} {tachofAmp0[1]} {tachofAmp0[2]}"
# 正则表达式
pattern = r"\{([a-zA-Z0-9_]+)\[(\d+)\]\}"
# 匹配
match = re.findall(pattern, input_str)
print(match)