goeway wrote: ↑July 25th, 2019, 4:52 am
A total of 100 days of data, but not sure if it will change, in this case, how to use regexp to get the data of 2019-07-24, which is the data of the last date (translate by google)
I'm not sure I completely understood, but at least if I did, here is a (possible) solution.
So, I suppose you have a site, where those information are shown. All of them have the same structure, but the dates (and probably the strings as well) are different (supposably in order) and you'd like to get the last date. Am I right?
If I am, you'd need to use a
Lookahead Assertion, especially if you don't know how many dates are there. This will ensure you the parent WebParser measure ([MeasureRainmeter]) doesn't fail when no enough dates are on the site.
For each existing date, a variable is set to 1 (Date1 - Date10 - Just up to 10 dates for now, see below). Finally based on the number of the variables set to 1, a measure ([MeasureDates]) returns the last date in the list.
The following code works for now only with up to 10 dates. If needed, the code can be rewritten, adding further sections, to check even more information. But first please take a look to it and tell me if I indeed have correctly understood your need. To get this code to work, add the appropriate URL of the site you're working with to the URL option of the [MeasureRainmeter] measure.
Code: Select all
[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
[Variables]
Item=(?(?=.*regexp).*(\d{4}-\d{2}-\d{2}).*)
Date1=0
Date2=0
Date3=0
Date4=0
Date5=0
Date6=0
Date7=0
Date8=0
Date9=0
Date10=0
[MeasureRainmeter]
Measure=WebParser
UpdateRate=10
Url=- ADD HERE THE URL -
RegExp=(?siU)#Item##Item##Item##Item##Item##Item##Item##Item##Item##Item#
FinishAction=[!EnableMeasureGroup "Child"][!UpdateMeasureGroup "Child"]
[MeasureDate1]
Measure=WebParser
Url=[MeasureRainmeter]
StringIndex=1
IfMatch=\d{4}-\d{2}-\d{2}
IfMatchAction=[!SetVariable Date1 "1"]
IfNotMatchAction=[!SetVariable Date1 "0"]
Group=Child
Disabled=1
[MeasureDate2]
Measure=WebParser
Url=[MeasureRainmeter]
StringIndex=2
IfMatch=\d{4}-\d{2}-\d{2}
IfMatchAction=[!SetVariable Date2 "1"]
IfNotMatchAction=[!SetVariable Date2 "0"]
Group=Child
Disabled=1
[MeasureDate3]
Measure=WebParser
Url=[MeasureRainmeter]
StringIndex=3
IfMatch=\d{4}-\d{2}-\d{2}
IfMatchAction=[!SetVariable Date3 "1"]
IfNotMatchAction=[!SetVariable Date3 "0"]
Group=Child
Disabled=1
[MeasureDate4]
Measure=WebParser
Url=[MeasureRainmeter]
StringIndex=4
IfMatch=\d{4}-\d{2}-\d{2}
IfMatchAction=[!SetVariable Date4 "1"]
IfNotMatchAction=[!SetVariable Date4 "0"]
Group=Child
Disabled=1
[MeasureDate5]
Measure=WebParser
Url=[MeasureRainmeter]
StringIndex=5
IfMatch=\d{4}-\d{2}-\d{2}
IfMatchAction=[!SetVariable Date5 "1"]
IfNotMatchAction=[!SetVariable Date5 "0"]
Group=Child
Disabled=1
[MeasureDate6]
Measure=WebParser
Url=[MeasureRainmeter]
StringIndex=6
IfMatch=\d{4}-\d{2}-\d{2}
IfMatchAction=[!SetVariable Date6 "1"]
IfNotMatchAction=[!SetVariable Date6 "0"]
Group=Child
Disabled=1
[MeasureDate7]
Measure=WebParser
Url=[MeasureRainmeter]
StringIndex=7
IfMatch=\d{4}-\d{2}-\d{2}
IfMatchAction=[!SetVariable Date7 "1"]
IfNotMatchAction=[!SetVariable Date7 "0"]
Group=Child
Disabled=1
[MeasureDate8]
Measure=WebParser
Url=[MeasureRainmeter]
StringIndex=8
IfMatch=\d{4}-\d{2}-\d{2}
IfMatchAction=[!SetVariable Date8 "1"]
IfNotMatchAction=[!SetVariable Date8 "0"]
Group=Child
Disabled=1
[MeasureDate9]
Measure=WebParser
Url=[MeasureRainmeter]
StringIndex=9
IfMatch=\d{4}-\d{2}-\d{2}
IfMatchAction=[!SetVariable Date9 "1"]
IfNotMatchAction=[!SetVariable Date9 "0"]
Group=Child
Disabled=1
[MeasureDate10]
Measure=WebParser
Url=[MeasureRainmeter]
StringIndex=10
IfMatch=\d{4}-\d{2}-\d{2}
IfMatchAction=[!SetVariable Date10 "1"]
IfNotMatchAction=[!SetVariable Date10 "0"]
Group=Child
Disabled=1
[MeasureDates]
Measure=Calc
Formula=( #Date1# + #Date2# + #Date3# + #Date4# + #Date5# + #Date6# + #Date7# + #Date8# + #Date9# + #Date10# )
DynamicVariables=1
RegExpSubstitute=1
Substitute="^(\d{1,3})$":"[&MeasureDate[&#CURRENTSECTION#]]"
Group=Child
Disabled=1
[MeterLastDate]
Meter=STRING
MeasureName=MeasureDates
X=0
Y=0
Padding=15,5,15,5
FontColor=220,220,220
FontEffectColor=0,0,0
StringEffect=Shadow
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=Last date:#CRLF#%1