regex - Regular expression retrive the ID from JSON string. The 1st ID after occurnace of "State Code": -


i want regex match " 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     } } 

even while regular expression not best tool job, can use 1 :

"address":\s*{[^}]*"id":\s*(\d+), 

for example in javascript do

var id = str.match(/"address":\s*{[^}]*"id":\s*(\d+),/); 

it similar in other languages (in many languages have escape \ in string literal).


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -