Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要 Python 正则表达式的帮助来提取单引号或双引号内的字符串。我找到了一个解决方案,但正则表达式在 C# 中:
如何提取引号中的字符串(双引号或单引号)
我需要解析这个字符串
tags = { 'one' : "two", "three", 'four' }
并返回数组项:
one two three four
目前我有这个单引号:
quoted = re.findall(r"'(.*?)'", buffer, re.DOTALL)
>>> buffer="tags = { 'one' : \"two\", \"three\", 'four' }" >>> re.findall(r"['\"](.*?)['\"]", buffer) ['one', 'two', 'three', 'four']