如果你觉得标题有点晦涩,我的意思是:我在寻找每一个以哈希符号(#
)开头的模式,然后匹配该符号之后的所有内容,直到找到另一个哈希或另一个定义的条目,但最后一个哈希或其他条目不应该是匹配的一部分
举个例子:
#one_liner = some cr4zy && weird stuff h3r3 $% ()
#multi_liner =some other s7uff,
but put in (other) line
#one_liner_again = again, some stuff here...
LB: this line shouldn't be taken into consideration!
#multi_liner_again=You guessed:
going to another line!
<EOF>
我想以四个匹配结束,例如包含这样一组元组:
("one_liner", "some cr4zy && weird stuff h3r3 \$\% ()")
("multi_liner", "some other s7uff, but put in (other) line")
("one_liner_again", "again, some stuff here...")
("multi_liner_again", "You guessed: going to another line!")
我尝试过这种模式,但它没有带来我想要的:
#\w.+\s*=(\s*|\S*.+)\w.+\n*\s*.+(?=#)
这可能会让您开始…您可能会希望除去找到的
\n
值和不需要的空格印刷品:
相关问题 更多 >
编程相关推荐