比方说,我们有一个字符串如何在多行字符串中捕获特定字符和字符串之间的字符串? Python的
string="This is a test code [asdf -wer -a2 asdf] >(ascd asdfas -were)\
test \
(testing test) test >asdf \
test"
我需要获得字符之间的字符串>和字符串“测试”。
我试图
re.findall(r'>[^)](.*)test',string, re.MULTILINE)
但是我得到
(ascd asdfas -were)\ test \ (testing test) test >asdf.
不过,我需要:
(ascd asdfas -were)\
和
asdf
我怎样才能得到那2个字符串?
所以,我试图修复你的代码块,你能确认它们是否符合你的意图吗? – jedwards
谢谢。这是我想要的 – Sam
这里有一个伟大的正则表达式生成器帮助您测试https://regex101.com/#python – ti7