It is currently March 28th, 2024, 8:33 pm

Error: "nothing to repeat"

Get help with creating, editing & fixing problems with skins
User avatar
Mordasius
Posts: 1167
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Error: "nothing to repeat"

Post by Mordasius »

I'm trying to update the time zone in a skin using the following:

Code: Select all

[Variables]
Latitude=52.479699
Longitude=-1.902691
tZone= +2

[mLocLatLongTzone]
Measure=Plugin
Plugin=WebParser
; returns current time and time zone for given latitude and longitude
Url=https://www.timeanddate.com/time/zone/@#latitude#,#longitude#
RegExp="(?siU).*data-clock-showSeconds.*class=h1>(.*:.*):.*</span>.*Current Offset.*UTC/GMT(.*)hour"
FinishAction=[!EnableMeasureGroup LocDat] [!UpdateMeasure *]
UpdateRate=84600

[mLocalTime]
Measure=WebParser
Url=[mLocLatLongTzone]
StringIndex=1
Group=LocDat
Disabled=1
[mLocationTzone]
Measure=WebParser
Url=[mLocLatLongTzone]
StringIndex=2
IfMatch=#tZone#
IfNotMatchAction=[!WriteKeyValue Variables tZone [mLocationTzone] "#SettingsFile#"] 
Group=LocDat
Disabled=1

[MeterString]
Meter=String
The problem is that I get the error message

Error: "nothing to repeat" in IfMatch=+2 (aaaTesting\aaaTesting.ini - [mLocationTzone])

Does anyone know what causes the error and what I can do about it?
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Error: "nothing to repeat"

Post by mak_kawa »

Hi Mordasius

Just my guess... "+" should be escaped in IfMatch expression? As a test, I modified the line to IfMatch=\#tZone#, the "nothing to repeat" error is gone. And, a file error occurred on !WriteKeyValue, so I think the IfMatchAction works correctly.
(But for RegExp matching error, it doesn't work for me...)

If I am misunderstanding at all. sorry.
User avatar
Yincognito
Rainmeter Sage
Posts: 7026
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Error: "nothing to repeat"

Post by Yincognito »

Mordasius wrote: August 20th, 2020, 12:03 pm I'm trying to update the time zone in a skin using the following:

Code: Select all

[Variables]
Latitude=52.479699
Longitude=-1.902691
tZone= +2

[mLocLatLongTzone]
Measure=Plugin
Plugin=WebParser
; returns current time and time zone for given latitude and longitude
Url=https://www.timeanddate.com/time/zone/@#latitude#,#longitude#
RegExp="(?siU).*data-clock-showSeconds.*class=h1>(.*:.*):.*</span>.*Current Offset.*UTC/GMT(.*)hour"
FinishAction=[!EnableMeasureGroup LocDat] [!UpdateMeasure *]
UpdateRate=84600

[mLocalTime]
Measure=WebParser
Url=[mLocLatLongTzone]
StringIndex=1
Group=LocDat
Disabled=1
[mLocationTzone]
Measure=WebParser
Url=[mLocLatLongTzone]
StringIndex=2
IfMatch=#tZone#
IfNotMatchAction=[!WriteKeyValue Variables tZone [mLocationTzone] "#SettingsFile#"] 
Group=LocDat
Disabled=1

[MeterString]
Meter=String
The problem is that I get the error message

Error: "nothing to repeat" in IfMatch=+2 (aaaTesting\aaaTesting.ini - [mLocationTzone])

Does anyone know what causes the error and what I can do about it?
I've made a couple of modifications to your code, mainly regarding spaces and escaping the reserved RegExp characters as mak_kawa correctly pointed out - this should work (I added a log message just to be sure, feel free to remove it):

Code: Select all

[Variables]
Latitude=52.479699
Longitude=-1.902691
tZone=" +2"

[mtZone]
Measure=String
String="#tZone#"
UpdateDivider=-1

[mLocLatLongTzone]
Measure=Plugin
Plugin=WebParser
; returns current time and time zone for given latitude and longitude
Url=https://www.timeanddate.com/time/zone/@#latitude#,#longitude#
RegExp="(?siU).*data-clock-showSeconds.*class=h1>(.*:.*):.*</span>.*Current Offset.*UTC/GMT(.*) hour"
FinishAction=[!EnableMeasureGroup LocDat] [!UpdateMeasure *]
UpdateRate=84600

[mLocalTime]
Measure=WebParser
Url=[mLocLatLongTzone]
StringIndex=1
Group=LocDat
Disabled=1
[mLocationTzone]
Measure=WebParser
Url=[mLocLatLongTzone]
StringIndex=2
IfMatch=^[mtZone:EscapeRegExp]$
IfNotMatchAction=[!Log "Time Zone ([mLocationTzone]) different from #tZone#"][!WriteKeyValue Variables tZone [mLocationTzone] "#SettingsFile#"] 
Group=LocDat
Disabled=1
DynamicVariables=1

[MeterString]
Meter=String
mak_kawa wrote: August 20th, 2020, 12:19 pmJust my guess... "+" should be escaped in IfMatch expression? As a test, I modified the line to IfMatch=\#tZone#, the "nothing to repeat" error is gone. And, a file error occurred on !WriteKeyValue, so I think the IfMatchAction works correctly.
While you are absolutely correct about the need to escape the "+", I'm not sure your method is the best one possible, because the parsing results in a timezone number preceded by space - so by doing IfMatch=\#tZone# I believe you're actually escaping the space and not the "+". I could be wrong, though.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Mordasius
Posts: 1167
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: Error: "nothing to repeat"

Post by Mordasius »

Thank you both for your prompt and helpful replies.
mak_kawa wrote: August 20th, 2020, 12:19 pm Just my guess... "+" should be escaped in IfMatch expression? As a test, I modified the line to IfMatch=\#tZone#
This does the job nicely thank you. It retains the "+" or "-" in the tZone variable which is essential since +2 hours is very different from -2 hours when it comes to calculating sunrise / sunset / moonrise / moonset etc.
Yincognito wrote: August 20th, 2020, 1:42 pm IfMatch=^[mtZone:EscapeRegExp]$
This also works but seems to detect a difference on every update which is fine until I start being a naughty chappy and adding a [!Refresh] bang to the FinishAction.

I still don't know what the "nothing to repeat" error was all about. Can anyone help on that one?
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: Error: "nothing to repeat"

Post by ikarus1969 »

Mordasius wrote: August 20th, 2020, 4:10 pm I still don't know what the "nothing to repeat" error was all about. Can anyone help on that one?
As the plus-sign usually says "repeat whatever (character, character set, character class, ...) preceeds the plus-sign at least once to eventually get a match" and as there is no character before the plus, there's "nothing to repeat". The regular-expression interpreter does not know what to look at that should occur one or more times.

edit: a regular expression of "a+" says there has to be at least one "a" to get a match
User avatar
Yincognito
Rainmeter Sage
Posts: 7026
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Error: "nothing to repeat"

Post by Yincognito »

Mordasius wrote: August 20th, 2020, 4:10 pmThis does the job nicely thank you. It retains the "+" or "-" in the tZone variable which is essential since +2 hours is very different from -2 hours when it comes to calculating sunrise / sunset / moonrise / moonset etc.
Your IfMatch doesn't use the ^ and $ (start and end of string) regex anchors, so it will match "+2" no matter where it is in the string. This might cause some inconsistencies (or better said, downright wrong results) for timezones like New Delhi, India, since your IfMatch will match the "+5" timezone (assuming that's the value of the tZone variable) even though the city's timezone is actually "+5:30" (i.e. +5 hours and 30 minutes). But then, you do as you wish... :confused:
Mordasius wrote: August 20th, 2020, 4:10 pmThis also works but seems to detect a difference on every update which is fine until I start being a naughty chappy and adding a [!Refresh] bang to the FinishAction.
But why would you do that? :lol: Beside making not much sense, I mean, if you really want to break things, you will break them no matter the code, right? :confused:
Mordasius wrote: August 20th, 2020, 4:10 pmI still don't know what the "nothing to repeat" error was all about. Can anyone help on that one?
I believe it was related to the fact that:
1. Rainmeter strips the leading and trailing spaces from things in certain circumstances, so you're probably left with "+2" in the IfMatch.
2. Since "+" is a regex quantifier which means "match 1 or more of the preceding token" and there's no preceding token as "+" is probably the first character in the IfMatch, the regex has "no token to repeat".

EDIT: Ikarus1969 already mentioned the last bit earlier, but since it was already written in my post, I left it there. No harm done, I suppose. :D
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth