It is currently April 28th, 2024, 8:15 am

Little Help with RegExp / Search String showing in output

Get help with creating, editing & fixing problems with skins
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Little Help with RegExp / Search String showing in output

Post by jsmorley »

I see the confusion...

You are ending up with something like:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]

[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
That will be confused by the fact that there is a (capture) in the first parent, [MeasureSite], and you are using that measure as the source for another parent measure [MeasureReviews], then adding a StringIndex to it. That StringIndex will refer to the first parent, as if it was a normal "parent / child" pair of measures. So what is happening here is:

[MeasuresSite] creates a string value of the entire string, as a capture of the entire string, indexed in StringIndex 1.
[MeasureReviews] uses that measure as the source, and has a RegExp that matches some part of it.
[MeasureReviews] also creates it's own capture group, indexed in StringIndex 1.

However, since [MeasureReviews] is a "child", the StringIndex option on it references the "parent", and then creates a "match" based on the RegExp on the child. That will be reviews_available":19,. Again, it also creates it's own StringIndex number with it's own capture, but isn't using it.

What you would need in this case is:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]

[MeasureSite]
Measure=WebParser
URL=file://#CURRENTPATH#Test.html
RegExp=(?siU)^(.*)$

[MeasureReviews]
Measure=WebParser
URL=[MeasureSite]
RegExp=(?siU)reviews_available":(.*),
StringIndex2=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
Note the StringIndex2.

https://docs.rainmeter.net/manual/measures/webparser/#StringIndex2
User avatar
balala
Rainmeter Sage
Posts: 16183
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Little Help with RegExp / Search String showing in output

Post by balala »

Oh, now I see. I never used StringIndex2 before, but it is trick enough. I read about it a few times, but had never use it. I have to study your example, but it definitely works.
So, as usually, I thank you for these explanations. There is always something new to be learned with Rainmeter.
:thumbup: :great:
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Little Help with RegExp / Search String showing in output

Post by jsmorley »

balala wrote: November 20th, 2018, 2:48 pm Oh, now I see. I never used StringIndex2 before, but it is trick enough. I read about it a few times, but had never use it. I have to study your example, but it definitely works.
So, as usually, I thank you for these explanations. There is always something new to be learned with Rainmeter.
:thumbup: :great:
WebParser is tricky, but VERY flexible.
User avatar
balala
Rainmeter Sage
Posts: 16183
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Little Help with RegExp / Search String showing in output

Post by balala »

jsmorley wrote: November 20th, 2018, 2:49 pm WebParser is tricky, but VERY flexible.
Agree...