I resist that...
It is currently May 10th, 2024, 12:53 am
Little Help with RegExp / Search String showing in output
-
- Developer
- Posts: 22632
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Little Help with RegExp / Search String showing in output
-
- Developer
- Posts: 22632
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Little Help with RegExp / Search String showing in output
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Variables]
[MeasureReviews]
Measure=WebParser
URL=file://#CURRENTPATH#Test.html
RegExp=(?siU)reviews_available":(.*),
StringIndex=1
[MeterResult]
Meter=String
MeasureName=MeasureReviews
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Code: Select all
{"reviews_available":19,"next_review_date":1541692800,"reviews_available_next_hour":19,"reviews_available_next_day":19}}
You do not have the required permissions to view the files attached to this post.
-
- Developer
- Posts: 22632
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Little Help with RegExp / Search String showing in output
You are confusing / conflating [MeasureSite] with [MeasureReviews].
For his simple purposes, you can have a "parent' of [MeasureSite] and a "child" of [MeasureReviews], or you can have a single measure that is BOTH a "parent" and a "child", call it either name, MeasureSite or MeasureReviews, that isn't important.
-
- Rainmeter Sage
- Posts: 16207
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Little Help with RegExp / Search String showing in output
No, I don't. What I meant was that if I use the code posted by you here:
I get reviews_available":19,, even if I add the StringIndex=1 option to [MeasureReviews] (obviously I replaced the URL option of [MeasureSite]).jsmorley wrote: ↑November 20th, 2018, 1:02 pmCode: Select all
[MeasureSite] Measure=Webparser URL=https://bunpro.jp/api/user/#APIKey#/study_queue RegExp=(?siU)^(.*)$ [MeasureReviews] Measure=Webparser URL=[MeasureSite] RegExp=(?siU)reviews_available":(.*),
-
- Developer
- Posts: 22632
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Little Help with RegExp / Search String showing in output
The long and the short of it is that WebParser can take a minute to wrap your head around, but once you do, it follows pretty simple rules:
1) Any WebParser measure with a RegExp on it is a "parent". It does two things, it returns the entire "match" created by the regular expression as the string value of the measure, and creates an index table of any (capture groups) that are defined in the regular expression.
2) Any WebParser measure with a StringIndex on it is a "child". It does one thing. It extracts the value of the indexed (capture group) from the parent, and sets that as the string value of the measure.
1) Any WebParser measure with a RegExp on it is a "parent". It does two things, it returns the entire "match" created by the regular expression as the string value of the measure, and creates an index table of any (capture groups) that are defined in the regular expression.
2) Any WebParser measure with a StringIndex on it is a "child". It does one thing. It extracts the value of the indexed (capture group) from the parent, and sets that as the string value of the measure.
-
- Rainmeter Sage
- Posts: 16207
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Little Help with RegExp / Search String showing in output
Ok, but in this case, if I added a StringIndex=1 option to [MeasureReviews], is it a parent or a child measure? Because it has both, a RegExp and a StringIndex.jsmorley wrote: ↑November 20th, 2018, 2:13 pm The long and the short of it is that WebParser can take a minute to wrap your head around, but once you do, it follows pretty simple rules:
1) Any WebParser measure with a RegExp on it is a "parent". It does two things, it returns the entire "match" created by the regular expression as the string value of the measure, and creates an index table of any (capture groups) that are defined in the regular expression.
2) Any WebParser measure with a StringIndex on it is a "child". It does one thing. It extracts the value of the indexed (capture group) from the parent, and sets that as the string value of the measure.
-
- Developer
- Posts: 22632
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Little Help with RegExp / Search String showing in output
To do this with the usual "parent / child" approach, it would look like:
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Variables]
[MeasureSite]
Measure=Webparser
URL=file://#CURRENTPATH#Test.html
RegExp=(?siU)reviews_available":(.*),
[MeasureReviews]
Measure=Webparser
URL=[MeasureSite]
StringIndex=1
[MeterResult]
Meter=String
MeasureName=MeasureReviews
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
-
- Developer
- Posts: 22632
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Little Help with RegExp / Search String showing in output
To use one measure as both "parent" and "child", it would look like:
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Variables]
[MeasureReviews]
Measure=WebParser
URL=file://#CURRENTPATH#Test.html
RegExp=(?siU)reviews_available":(.*),
StringIndex=1
[MeterResult]
Meter=String
MeasureName=MeasureReviews
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
-
- Developer
- Posts: 22632
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Little Help with RegExp / Search String showing in output
In a sense, it ends up as a "child" measure, as the final string value will be the (capture) based on the StringIndex. It plays both roles however, as it uses the RegExp to create the "match" and index the captures, then turns around and uses the index to set the final string value.
-
- Rainmeter Sage
- Posts: 16207
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Little Help with RegExp / Search String showing in output
Yep, both code posted above are good, understandable and work as they should.jsmorley wrote: ↑November 20th, 2018, 2:22 pm In a sense, it ends up as a "child" measure, as the final string value will be the (capture) based on the StringIndex. It plays both roles however, as it uses the RegExp to create the "match" and index the captures, then turns around and uses the index to set the final string value.
However my question is still the same (but it seems we didn't understand each other): I have the following code:
Code: Select all
[MeasureSite]
Measure=Webparser
URL=file://#CURRENTPATH#Test.html
RegExp=(?siU)^(.*)$
[MeasureReviews]
Measure=Webparser
URL=[MeasureSite]
RegExp=(?siU)reviews_available":(.*),
StringIndex=1
[MeterResult]
Meter=String
MeasureName=MeasureReviews
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
I'm sorry to bother you, but still isn't clear to me.