I need to fix one "last" issue with my improved skin parsing the output of a certain api and displaying blood glucose values:
- My RegExp works fine for "my" cloud server api output (for those who are interested it's the "Nightscout pebble api")
- However, it should also work for other people who can have the server configured slightly differently
- Especially, some of the parsed strings might be missing for other users, see example as follows
Here's the problematic RegExp:
Code: Select all
RegExp=(?siU)now":(.*)}],.*sgv":"(.*)",.*trend":(.*),.*direction":"(.*)",.*datetime":(.*),.*bgdelta":(.*),.*iob":"(.*)",.*cob":(.*)}
; Output StringIndex
; 1 - Current Time
; 2 - Glucose
; 3 - Delta [Not used]
; 4 - Direction (Text)
; 5 - Glucose Timestamp
; 6 - BG Delta
; 7 - IOB
; 8 - COB
{"status":[{"now":1667747473294}],"bgs":
[{"sgv":"131","trend":4,"direction":"Flat","datetime":1667747202471,
"bgdelta":5,"battery":"96","iob":"6.86","bwp":"-5.11","bwpo":-88,"cob":57.8}],"cals":[]}
However, here's the api output of a different user/server as another example (again, linebreaks added for comparison):
{"status":[{"now":1668113492344}],"bgs":
[{"sgv":"117","trend":4,"direction":"Flat","datetime":1668113241000,
"bgdelta":2}],"cals":[]}
As you can see, the strings can vary in order (which is no problem for the RegExp) but also certain strings can be missing completely, because the other user/server does not need or does not have these specific options. In this example strings 7+8 called "IOB" and "COB" are missing. Therefore, my RexExp and the skin simply fails to display any data. I got feedback from users that my skin "does not work" and I could now prove this with the RainRegExp tool: The variable api output is obviously the reason behind.
Now my question: How can I make the above RexExp work (and not fail) for situations when certain strings are missing? In such cases I would like the RegExp to return all existing string values and simply leave the missing strings empty, in this case it should return "" for IOB and COB. Hopefully there is some error handling functionality telling Rainmeter to ignore missing RegExp strings? Could not find this in the documentation yet.
Thanks so much for your help (again)!!