我有一个要用正则表达式测试的json字符串:
字符串:
{“完成”:true,“ dateCompleted”:1533718801871,“ dateCreated”:1533718800064,“ detailedStatus”:null,“ executing”:false,“ failedOps”:0,“ failureReason”:null,“ opsCompleted”: 11,“ opsExpected”:null,“ progress”:null,“ returnValue”:null,“ serverId”:“ lvt-guwccb-j013”,“ startDate”:1533718801613,“ starting”:false,“ startingOrExecuting”:false, “ success”:true,“ type”:“ ActivityEsc”}
我想确定是否完整或成功字段之一为假。为此,我想结合两个表达式:
("complete":)(?=true)
和
("success":)(?=true)
据我所读,我希望可以一次又一次地编写它们,因此隐式地将它们视为AND。
如果我在表达式之间使用or(|)运算符,则会得到一个匹配项,这对我来说很奇怪。 有什么建议吗?
答案 0 :(得分:0)
您可以根据情况使用以下简单的正则表达式:
("complete":)(?=true).+("success":)(?=true)
因此,如果上述声明为false,则表示complete / success均为false,否则它将为true。