【发布时间】:2021-08-24 14:33:14
【问题描述】:
对不起,我不知道如何命名这个线程。
我需要从string 中提取() 和"" 的第一层,但是当我尝试使用re 时,它只会返回第一层和第二层() 之间的所有内容。
import re
string = 'this is a test ("string with (some) paranthesis") how great'
extract = re.findall('\((.*?)\)', string)
print(extract)
输出:
['"string with (some']
但我需要:
['"string with (some) paranthesis"']
或者没有""。
【问题讨论】: