【发布时间】:2016-12-08 01:32:00
【问题描述】:
假设我们有一个字符串
string="This is a test code [asdf -wer -a2 asdf] >(ascd asdfas -were)\
test \
(testing test) test >asdf \
test"
我需要获取字符 > 和字符串“test”之间的字符串。
我试过了
re.findall(r'>[^)](.*)test',string, re.MULTILINE )
但是我得到了
(ascd asdfas -were)\ test \ (testing test) test >asdf.
但我需要:
(ascd asdfas -were)\
与
asdf
我怎样才能得到那两个字符串?
【问题讨论】:
-
所以,我试图修复你的代码块,你能确认它们是你想要的吗?
-
谢谢。这就是我想要的
-
这是一个很棒的正则表达式生成器,可以帮助您测试regex101.com/#python
标签: python regex python-2.7 python-3.x