我目前正在尝试编写一个正则表达式,该表达式只会提取分配给state:
标记的值,而不考虑除标题之外的其他参数的顺序。
例如:
addcard "My card title" assigned: @username @username2 state: ready to
deploy due: Next Wednesday project: tooling #tag1 #tag2 #tag3
addcard "My card title" state:ready to deploy assigned: @username
@username2 due: Next Wednesday project: tooling #tag1 #tag2 #tag3
addcard "My card title" #tag1 #tag2 #tag3 state: ready to deploy
assigned: @username @username2 due: Next Wednesday project: tooling
应该全部返回:ready to deploy
或state:ready to deploy
或state: ready to deploy
我尝试使用否定查找,但我开始认为我可能不太了解负面查找。
我当前的正则表达式:regex101
答案 0 :(得分:0)
尝试类似:
pygame.draw.rect(self.surface, white, (self.height, self.height, self.width, self.width))
答案 1 :(得分:0)
@ Jack的答案很聪明,因为它使用的模式也巧妙地省略了终结符,因为它表明我们想要与一个以空格结尾的单词匹配。终止符是以冒号结尾的单词。
对@ Jack的答案的改进是省略任何前导空格:
state:\s*([\w\s]+)\s