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

Help: Rainmeter Skins • Re: RegExp - parsing "simple" text file with Key=Value ending with newline

$
0
0
Dear Team, I did "my best" in the last hours, but I continue to fail with this "simple" task. Could you please have a quick look, why this regexp does not work? I always get RegExp matching error (-1)

Goal: Capturing these 7 strings/values from below file1.txt file in a standard Key=Value(newline) format:
1) 20240616164427
2) 22
3) (Updated 12 mins ago)
4) 12
5) 0.1
6) 14.5
7) <div style=XXXXX</div>
Well, the matter is indeed simple, your pattern basically doesn't match the file string, being otherwise correct, see the comments in the code below:

Code:

[Rainmeter]Update=1000AccurateText=1DynamicWindowSize=1---Measures---[Parser1]Measure=WebParserUpdateRate=600URL=file://#CURRENTPATH#file1.txt; GOODRegExp=(?siU)LastRunTime=(.*)\nTotalRuntime\(secs\)=(.*)\n.*\nLastUpdatedAgo_Original=(.*)\nLastUpdatedAgo_minutes=(.*)\n.*\nImported_kWh=(.*)\nProduced_kWh=(.*)\n.*\nMetricsTrend_pos_SVG=(.*)\n; BAD (reasons: the lack of additional .*\n in the pattern to skip the (A)..., (B)... and (C)... parts and the file string missing the CurrentBatteryCharge... and MetricsTrend_neg_SVG... parts existing in the pattern);RegExp=(?siU)LastRunTime=(.*)\nTotalRuntime\(secs\)=(.*)\nLastUpdatedAgo_Original=(.*)\nLastUpdatedAgo_minutes=(.*)\nCurrentBatteryCharge=(.*)\nImported_kWh=(.*)\nProduced_kWh=(.*)\n\nMetricsTrend_pos_SVG=(.*)\nMetricsTrend_neg_SVG=(.*)\nDynamicVariables=1[Capture1]Measure=WebParserURL=[Parser1]StringIndex=1[Capture2]Measure=WebParserURL=[Parser1]StringIndex=2[Capture3]Measure=WebParserURL=[Parser1]StringIndex=3[Capture4]Measure=WebParserURL=[Parser1]StringIndex=4[Capture5]Measure=WebParserURL=[Parser1]StringIndex=5[Capture6]Measure=WebParserURL=[Parser1]StringIndex=6[Capture7]Measure=WebParserURL=[Parser1]StringIndex=7---Meters---[Result]Meter=StringFontFace=ConsolasFontSize=12FontColor=160,160,160,255SolidColor=0,0,0,128AntiAlias=1InlineSetting=Color | 255,255,255,255InlinePattern=(.* =)MeasureName =Capture1MeasureName2=Capture2MeasureName3=Capture3MeasureName4=Capture4MeasureName5=Capture5MeasureName6=Capture6MeasureName7=Capture7Text=Result =#CRLF#1) %1#CRLF#2) %2#CRLF#3) %3#CRLF#4) %4#CRLF#5) %5#CRLF#6) %6#CRLF#7) %7DynamicVariables=1
Mismatch.jpg
Regex.jpg
Note: I assumed your file contents is the last code section that you posted above AND that it ends with a newline, being just a regular (i.e. UTF-8) encoded file in the Windows' Notepad. If by any chance the encoding is different, you'll need to add / adjust the CodePage option in [Parser1]:
https://docs.rainmeter.net/manual/measures/webparser/#CodePage

Statistics: Posted by Yincognito — Yesterday, 5:22 pm



Viewing all articles
Browse latest Browse all 1065

Trending Articles