我试图从文本中提取队列信息和成员,直到空行或下一个队列,但只选择队列信息没有成员(我读了很多帖子,但没有成功。请告诉我解决问题的正确方向
我使用python 3.9最后一次测试的正则表达式
^[wd]+.*(?!nn)
请参阅regex101的数据示例
https://regex101.com/r/kCrTIN/1
可以这样做。
它匹配到下一个空行或文件末尾。
(?sm)^[wd]+.*?(?=r?ns*r?n|z)
https://regex101.com/r/vXZI8V/1
(?sm) # Flags: dot-all, multi-line
^ [wd]+ .*? # Begin of line matches 'queue'
(?= r?n s* r?n | z ) # Keep matching until ahead is a blank line 'ns*n' typical
# or end of file 'z'