Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 73

Help: Rainmeter Application • Re: WebParser.dll Missing After Rainmeter Installation

$
0
0
Kindly guide me on how to use correct Regexp
I think he actually did, also included the right guides as references for you to read which are much more descriptive.

However, it's not that hard. For most cases you only need to understand that you start the regexp with "(?siU)" and then use ".*" and "(.*)". If you parse some website and you add the line debug2file=2 a file will be created with the parser return. You just need to check the file and create the regexp to capture the information you need and omit the one you don't need. You capture stuff with "(.*)" and omit stuff with ".*". Each (.*) is an string index and it's value is retrieved by a child measure.

Given the parsed code:

Code:

{    "status": "ok",    "data": {        "aqi": 173,        "idx": 7024,        "attributions": [            {                "url": "http://worldweather.wmo.int",                "name": "World Meteorological Organization - surface synoptic observations (WMO-SYNOP)"            },            {                "url": "https://in.usembassy.gov/embassy-consulates/new-delhi/air-quality-data/",                "name": "U.S. Embassy and Consulates' Air Quality Monitor in India",                "logo": "US-StateDepartment.png"            },            {                "url": "https://waqi.info/",                "name": "World Air Quality Index Project"            }        ],        "city": {            "geo": [                28.63576,                77.22445            ],            "name": "New Delhi US Embassy, India (नई दिल्ली अमेरिकी दूतावास)",            "url": "https://aqicn.org/city/india/new-delhi/us-embassy",            "location": ""        },        "dominentpol": "pm25",        "iaqi": {            "dew": {                "v": 10            },            "h": {                "v": 47.5            },            "p": {                "v": 1015            },            "pm25": {                "v": 173            },            "t": {                "v": 21.5            },            "w": {                "v": 0.5            }        },        "time": {            "s": "2024-11-24 20:00:00",            "tz": "+05:30",            "v": <a href="tel:1732478400">1732478400</a>,            "iso": "2024-11-24T20:00:00+05:30"        },        "forecast": {            "daily": {                "o3": [                    {                        "avg": 4,                        "day": "2024-11-22",                        "max": 37,                        "min": 1                    },                    {                        "avg": 5,                        "day": "2024-11-23",                        "max": 32,                        "min": 1                    },                    {                        "avg": 11,                        "day": "2024-11-24",                        "max": 30,                        "min": 1                    },                    {                        "avg": 12,                        "day": "2024-11-25",                        "max": 28,                        "min": 2                    },                    {                        "avg": 7,                        "day": "2024-11-26",                        "max": 33,                        "min": 1                    },                    {                        "avg": 4,                        "day": "2024-11-27",                        "max": 35,                        "min": 1                    },                    {                        "avg": 4,                        "day": "2024-11-28",                        "max": 36,                        "min": 1                    },                    {                        "avg": 1,                        "day": "2024-11-29",                        "max": 1,                        "min": 1                    }                ],                "pm10": [                    {                        "avg": 73,                        "day": "2024-11-22",                        "max": 73,                        "min": 73                    },                    {                        "avg": 96,                        "day": "2024-11-23",                        "max": 123,                        "min": 58                    },                    {                        "avg": 88,                        "day": "2024-11-24",                        "max": 123,                        "min": 58                    },                    {                        "avg": 83,                        "day": "2024-11-25",                        "max": 123,                        "min": 58                    },                    {                        "avg": 64,                        "day": "2024-11-26",                        "max": 73,                        "min": 46                    },                    {                        "avg": 78,                        "day": "2024-11-27",                        "max": 116,                        "min": 58                    },                    {                        "avg": 89,                        "day": "2024-11-28",                        "max": 123,                        "min": 58                    },                    {                        "avg": 86,                        "day": "2024-11-29",                        "max": 123,                        "min": 46                    },                    {                        "avg": 70,                        "day": "2024-11-30",                        "max": 73,                        "min": 46                    }                ],                "pm25": [                    {                        "avg": 168,                        "day": "2024-11-22",                        "max": 174,                        "min": 161                    },                    {                        "avg": 210,                        "day": "2024-11-23",                        "max": 252,                        "min": 159                    },                    {                        "avg": 198,                        "day": "2024-11-24",                        "max": 252,                        "min": 159                    },                    {                        "avg": 182,                        "day": "2024-11-25",                        "max": 252,                        "min": 159                    },                    {                        "avg": 162,                        "day": "2024-11-26",                        "max": 174,                        "min": 138                    },                    {                        "avg": 180,                        "day": "2024-11-27",                        "max": 232,                        "min": 157                    },                    {                        "avg": 198,                        "day": "2024-11-28",                        "max": 252,                        "min": 153                    },                    {                        "avg": 197,                        "day": "2024-11-29",                        "max": 252,                        "min": 138                    },                    {                        "avg": 171,                        "day": "2024-11-30",                        "max": 174,                        "min": 138                    }                ],                "uvi": [                    {                        "avg": 1,                        "day": "2024-11-24",                        "max": 4,                        "min": 0                    },                    {                        "avg": 1,                        "day": "2024-11-25",                        "max": 4,                        "min": 0                    },                    {                        "avg": 1,                        "day": "2024-11-26",                        "max": 4,                        "min": 0                    },                    {                        "avg": 1,                        "day": "2024-11-27",                        "max": 4,                        "min": 0                    },                    {                        "avg": 1,                        "day": "2024-11-28",                        "max": 4,                        "min": 0                    },                    {                        "avg": 0,                        "day": "2024-11-29",                        "max": 0,                        "min": 0                    }                ]            }        },        "debug": {            "sync": "2024-11-24T23:43:11+09:00"        }    }}
All you need is to identify what you want to retrieve, for simplicity I'll retrieve a 2 pieces of information only. Let's say we want to retrieve aqi and idx values. So looking at the code we just find what's before and after what we want to capture, in this case we'll only look at this part of the code:

Code:

{    "status": "ok",    "data": {        "aqi": 173,        "idx": 7024,        "attributions": [
So what's behind is "aqi": and after is a comma ,
So our regexp would look like this:

Code:

RegExp=(?siU).*"aqi":(.*),"idx":(.*),
The first ".*" is just "omitting" what's before "aqi": and the (.*) is capturing whatever is between "aqi": and the comma. Then, since right after the comma there's the "idx": line, we then don't need another ".*". So we just add "idx": followed by another (.*) to capture whatever it's between that and the last comma and that's it.

If there was more information between the first comma and the "idx": line then we would need to add an extra .* before it to omit that information.

Then you just need 2 child measures to retrieve the string indices, the first (.*) would be the index 1 and the second the index 2.

Statistics: Posted by RicardoTM — November 25th, 2024, 3:29 pm



Viewing all articles
Browse latest Browse all 73

Trending Articles