It is currently April 26th, 2024, 6:13 pm

[SOLVED] RegExp Matching Error -1

Get help with creating, editing & fixing problems with skins
User avatar
spoonwzd
Posts: 17
Joined: November 29th, 2017, 6:24 pm

[SOLVED] RegExp Matching Error -1

Post by spoonwzd »

Hoping someone can assist me with this...

I'm presenting a .txt file to the WebParser, but my expression isn't working.

The .txt file contains the following information:

Code: Select all

Message : Three Day Forecast

          

          Date: 2018-05-03 Total: 3004.066 Morning: 0

          Date: 2018-05-04 Total: 21160.36 Morning: 1518.377

          Date: 2018-05-05 Total: 31322.1 Morning: 4706.429
I want each 'Date' and 'Total' values in a total of 6 string indexes. I am using the following expression:

Code: Select all

(?siU).*Forecast.*Date: (.*) Total: (.*) Morning.*Date: (.*) Total: (.*) Morning.*Date: (.*) Total: (.*) Morning
The expression works just fine in RainRegExp, but when adding it to my RainMeter skin I get a RegExp matching error.

Stuff I've tried:
• Rainmeter has been restarted
• I have tried serving the .txt file via a web server (IIS)
• I have tried accessing using a file share with file://
• I've tried putting the expression in quotes

Please help - I didn't have that much hair to begin with as it is!
Last edited by spoonwzd on May 4th, 2018, 2:39 pm, edited 1 time in total.
User avatar
balala
Rainmeter Sage
Posts: 16173
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: RegExp Matching Error -1

Post by balala »

I have to say your RegExp works perfectly for me.
Please post the whole code of your skin.
User avatar
spoonwzd
Posts: 17
Joined: November 29th, 2017, 6:24 pm

Re: RegExp Matching Error -1

Post by spoonwzd »

Thanks for your response.

Here's the code so far:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1

[Metadata]
Name=PowerwallService SolCast Prediction Display
Author=spoonwzd
Information=PwS generated Solcast daily estimate display. Inspired by and designed to fit alongside the BlueVision skin by g3xter.
Version=1.0
License=Creative Commons Attribution - Non - Commercial - Share Alike 3.0

[Variables]
FontName=hooge 05_53
FontHeight=6
FontColor=206,231,249,255
BlueBorder=Border
BlueColor=0,148,255,128
GraphColor1=89,190,255,255
GraphColor2=65,176,200,200
AntiAlias=1
NoAntiAlias=0
Yes=1
No=0
Version=1.0

[Background]
Meter=Image
ImageName=#@#PwS Mini BG v1.png
X=0
Y=0
W=414
H=72

[MeasurePV]
Measure=WebParser
URL=file://d:\pwsforecast.txt
UpdateRate=1
RegExp=(?siU).*Forecast.*Date: (.*) Total: (.*) Morning.*Date: (.*) Total: (.*) Morning.*Date: (.*) Total: (.*) Morning

[Day0Date]
Measure=WebParser
URL=[MeasurePV]
StringIndex=1
UpdateDivider=1

[Title]
Meter=STRING
X=5
Y=2
FontColor=#FontColor#
FontSize=#FontHeight#
FontFace=#FontName#
StringEffect=#BlueBorder#
FontEffectColor=#BlueColor#
AntiAlias=#NoAntiAlias#
Text="Daily Solcast PV Generation Estimates"
UpdateDivider=-1

[Day0Title]
Meter=STRING
MeasureName=Day0Date
X=5
Y=20
FontColor=#FontColor#
FontSize=#FontHeight#
FontFace=#FontName#
StringEffect=#BlueBorder#
FontEffectColor=#BlueColor#
AntiAlias=#NoAntiAlias#
UpdateDivider=1
User avatar
balala
Rainmeter Sage
Posts: 16173
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: RegExp Matching Error -1

Post by balala »

spoonwzd wrote:Here's the code so far:
The [Day0Date] measure returns the first date (working perfectly). The skin works for me, but there are no other measures to return the other information.
If I add them, everything is returned as it should have to be. The following WebParser measures are needed:

Code: Select all

[Day0Date]
Measure=WebParser
URL=[MeasurePV]
StringIndex=1
UpdateDivider=1

[Day0Total]
Measure=WebParser
URL=[MeasurePV]
StringIndex=2
UpdateDivider=1

[Day1Date]
Measure=WebParser
URL=[MeasurePV]
StringIndex=3
UpdateDivider=1

[Day1Total]
Measure=WebParser
URL=[MeasurePV]
StringIndex=4
UpdateDivider=1

[Day2Date]
Measure=WebParser
URL=[MeasurePV]
StringIndex=5
UpdateDivider=1

[Day2Total]
Measure=WebParser
URL=[MeasurePV]
StringIndex=6
UpdateDivider=1
(I also included here the [Day0Date] measure, as you had it in your code).
Another missing piece is / are the String meter(s), which should show up the parsed information. Something like this:

Code: Select all

[MeterInfo]
MeasureName=Day0Date
MeasureName2=Day0Total
MeasureName3=Day1Date
MeasureName4=Day1Total
MeasureName5=Day2Date
MeasureName6=Day2Total
Meter=STRING
X=0
Y=40
Padding=15,5,15,5
FontColor=220,220,220
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=Left
AntiAlias=1
Text=1. %1 / %2#CRLF#2. %3 / %4#CRLF#3. %5 / %6
Adding the above measures and meter, I hope will make the skin to work properly. If doesn't, please restart Rainmeter (not just the skin, but the whole Rainmeter) (however you wrote you did this).
If still doesn't work, please check the Log. What is shown up there?
User avatar
spoonwzd
Posts: 17
Joined: November 29th, 2017, 6:24 pm

Re: RegExp Matching Error -1

Post by spoonwzd »

Thanks!

The other meters were there, but i stripped them out to reduce the code down to the bare minimum so as to ease troubleshooting.

Adding Text=%1 doesn't help, as it never actually gets data into the string index.

Restarting Rainmeter doesn't help either. The log just spams:

Code: Select all

RegExp matching error (-1) (PwS Solcast Prediciton Display\PwS Solcast Prediciton Display.ini - [MeasurePV])
My other skins are just fine. Am at a bit of a loss TBH.
User avatar
spoonwzd
Posts: 17
Joined: November 29th, 2017, 6:24 pm

Re: RegExp Matching Error -1

Post by spoonwzd »

Here's the actual .txt:

LINK REDACTED
Last edited by spoonwzd on May 4th, 2018, 6:53 am, edited 1 time in total.
User avatar
balala
Rainmeter Sage
Posts: 16173
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: RegExp Matching Error -1

Post by balala »

spoonwzd wrote:Here's the actual .txt:

https://gate.spoonwizard.com/pwsforecast.txt
Works for me!
Please pack the whole config you have (including the txt file) and attach it, to can check.
User avatar
spoonwzd
Posts: 17
Joined: November 29th, 2017, 6:24 pm

Re: RegExp Matching Error -1

Post by spoonwzd »

Here ya go

LINK REDACTED
Last edited by spoonwzd on May 4th, 2018, 6:53 am, edited 1 time in total.
User avatar
balala
Rainmeter Sage
Posts: 16173
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: RegExp Matching Error -1

Post by balala »

The problem is the encoding of the pwsforecast.txt file. Change it to ANSI and the skin will probably start working.
However the Url option seems a little bit weird to me. Are you sure it is ok?
User avatar
spoonwzd
Posts: 17
Joined: November 29th, 2017, 6:24 pm

Re: RegExp Matching Error -1

Post by spoonwzd »

Thanks, that sorted it.

For completeness; The txt file is actually redirected Powershell output of an event log. By using out-file instead of redirect with > I was able to define the encoding type:
get-eventlog -source servicename -logname application -InstanceId 1000 -newest 1 | select message | fl | out-file -filepath C:\inetpub\wwwroot\pwsforecast.txt -encoding ascii
Thanks again for your help!