我有如下文字:
qwerqwer asdf foo bar
%abc anchor
one
%abc anchor
one thow foo bar
%abc anchor
one two three
%abc anchor
现在我有了regexp(.+)\n\%\w+\sanchor
,但它给了我('qwerqwer asdf foo bar', 'one thow foo bar', 'one', 'one two three')
我想从结果字符串foo bar
中排除,并得到结果('qwerqwer asdf', 'one thow', 'one', 'one two three')
也许有人解决了类似的问题
您需要使用不情愿的修饰符(
+?
),这样它就不会吃foo bar
,并且在行的末尾添加一个可选的foo bar
https://regex101.com/r/fU2jA5/1
相关问题 更多 >
编程相关推荐