Home > Net >  C # a regular expression to extract value
C # a regular expression to extract value

Time:10-08

{" errno ": 0," data ": {" devices" : [{" title ":" monitor terminal ", "id" : "527240946", "datastreams" : [{" at ":" the 2019-07-31 19:06:06 ", "id" : "3325 _0_5700", "value" : 2}, {" at ":" the 2019-07-31 19:05:58 ", "id" : "3304 _0_5700", "value" : 0}, {" at ":" the 2019-07-31 18:55:56 ", "id" : "3303 _0_5700", "value" : 45.8}, {" at ":" the 2019-07-31 18:56:00 ", "id" : "3200 _0_5500", "value" : false}, {" at ":" the 2019-07-31 19:05:58 ", "id" : "3300 _0_5700", "value" : 0}, {" at ":" the 2019-07-31 19:05:43 ", "id" : "3315 _0_5700", "value" : 100560}]}]}, "error" : "succ"}



For help! Want to extract the id value, at the value, the value value, different way because the query, json structure is different also, so the regular expression is the most convenient way to extract string I want! A great god for help all of you!

CodePudding user response:

 Regex Matches (ori, "at ", \ "(. *?) \ \ ", \ "id" : \ "(. *?) Value \ \ ", \ "" : (. *?) } ") 

Take each Match Groups [1], the Groups [2], Groups [3]

CodePudding user response:

This is not a JSON? Maybe use JsonReader more convenient?

CodePudding user response:

How is this problem, it is not solved

CodePudding user response:

Results, please see: http://www.regexp.cn/Regex/index/1045

Suggest still use JSON to read,
  •  Tags:  
  • C#
  • Related