It is currently April 24th, 2024, 11:57 pm

Change in RegExp error url has been updated and is different - help new regexp. <solved>

Get help with creating, editing & fixing problems with skins
User avatar
CodeCode
Posts: 1366
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Change in RegExp error url has been updated and is different - help new regexp. <solved>

Post by CodeCode »

Hello,
I have been getting percent illuminated from http://iohelix.net/moon/moonlite.xml
From what I can see, a lot has changed over the weekend.

If anyone can help restructure the regexp, it would help a lot.

Code: Select all

[MeasureMoonPercent]
Measure=WebParser
Url=http://iohelix.net/moon/moonlite.xml
RegExp=(?siU)<moon>.*<elongationToSun>.*</elongationToSun>.*<percentIlluminated>(.*)</percentIlluminated>.*<age>.*</age>.*<phase>(.*)</phase>.*<length>.*</length>.*<nextPhase>.*<daysToPhase>.*</daysToPhase>.*</nextPhase></moon>
UpdateRate=900
StringIndex=1
The new data isnt really very long, I just don't do this kind of thing very often.
Thanks for any help.
Last edited by CodeCode on February 7th, 2023, 3:15 am, edited 1 time in total.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2604
Joined: March 23rd, 2015, 5:26 pm

Re: Change in RegExp error url has been updated and is different - help new regexp.

Post by SilverAzide »

CodeCode wrote: February 7th, 2023, 2:04 am Hello,
I have been getting percent illuminated from http://iohelix.net/moon/moonlite.xml
From what I can see, a lot has changed over the weekend.

If anyone can help restructure the regexp, it would help a lot.

Code: Select all

[MeasureMoonPercent]
Measure=WebParser
Url=http://iohelix.net/moon/moonlite.xml
RegExp=(?siU)<moon>.*<elongationToSun>.*</elongationToSun>.*<percentIlluminated>(.*)</percentIlluminated>.*<age>.*</age>.*<phase>(.*)</phase>.*<length>.*</length>.*<nextPhase>.*<daysToPhase>.*</daysToPhase>.*</nextPhase></moon>
UpdateRate=900
StringIndex=1
The new data isnt really very long, I just don't do this kind of thing very often.
Thanks for any help.
Tweak the very end of the regexp, like so: ...</nextPhase>.*</moon> (i.e., insert the bit in red).

This regexp looks like it was originally intended to grab a lot more data than just the percentage illuminated (it grabs the phase too, but not sure if you are using it). But if that is all you want, you can greatly simplify the expression by just using one or the other of the following:

Code: Select all

RegExp=(?siU)<percentIlluminated>(.*)</percentIlluminated>
RegExp=(?siU)<percentIlluminated>(.*)</percentIlluminated>.*<phase>(.*)</phase>
Gadgets Wiki GitHub More Gadgets...
User avatar
CodeCode
Posts: 1366
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Change in RegExp error url has been updated and is different - help new regexp.

Post by CodeCode »

Hi SIlverAzide.
This RegExp=(?siU)<percentIlluminated>(.*)</percentIlluminated> works great, but the log shows "not enough substrings".

Which actually does not matter to me very much but if I update this in DevArt end users might shy away from it.

Anyway, thanks for the help, and working solution! :thumbup:

EDIT: this fixed that (you provided this: <phase>(.*)</phase>).
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2604
Joined: March 23rd, 2015, 5:26 pm

Re: Change in RegExp error url has been updated and is different - help new regexp.

Post by SilverAzide »

CodeCode wrote: February 7th, 2023, 3:11 am Hi SIlverAzide.
This RegExp=(?siU)<percentIlluminated>(.*)</percentIlluminated> works great, but the log shows "not enough substrings".

Which actually does not matter to me very much but if I update this in DevArt end users might shy away from it.

Anyway, thanks for the help, and working solution! :thumbup:
The "not enough substrings" error is why I gave you two choices. Your post only showed one substring being used and two being captured, so I gave you the second option in case you were using both captures.
Gadgets Wiki GitHub More Gadgets...
User avatar
CodeCode
Posts: 1366
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Change in RegExp error url has been updated and is different - help new regexp.

Post by CodeCode »

SilverAzide wrote: February 7th, 2023, 3:15 am The "not enough substrings" error is why I gave you two choices. Your post only showed one substring being used and two being captured, so I gave you the second option in case you were using both captures.
I was, Just forgot. I was using the full or new phase to set a binary so the correct side of the moon was illuminated for either hemisphere of the planet. (north or south).

Thanks.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.