我想要一个正则表达式匹配“ID:1234”
{
{
Id:"",
"Address": {
"Deleted": false,
"Owner": 123,
"PartyId": 123,
"Modified": "11:41:29",
"AddressType": "BILLING",
**"StateCode":"Nw",**
**"Id": 1234,**
"CountryCode": "US",
"Version": 2,
"AddressLine2": "",
"OptimisticLock": 0
},
"PaymentMethodType": "CREDIT_CARD",
"LastInvoiceDate": "12:18:00",
"BillingDetailSet": [],
"BillingCycleDate": "12:18:00",
"Id": 15676
}
}
答案 0 :(得分:1)
即使正则表达式很可能不是这项工作的最佳工具,您也可以使用这个:
"Address":\s*{[^}]*"Id":\s*(\d+),
例如在JavaScript中你会做
var id = str.match(/"Address":\s*{[^}]*"Id":\s*(\d+),/);
在其他语言中也是如此(在许多语言中你必须逃避字符串文字中的\
)。
答案 1 :(得分:0)
“StateCode”:\ s *“\ w +”,\ s *“Id”:\ s *(\ d +),这对我有帮助