It is currently May 2nd, 2024, 12:18 am

Help with RegExp expression

Get help with creating, editing & fixing problems with skins
VoodooSin
Posts: 8
Joined: October 14th, 2010, 8:30 pm

Help with RegExp expression

Post by VoodooSin »

Ok, I'm normally all for figuring things out on my own until I'm completely stumped, but RegExp makes my head hurt. :) Could somebody look at this and see what I'm doing wrong, or even if this is possible to do with a standard html page? I know it's unrefined, but this is just my test phase right now, I'll make it prettier later...Thanks!

Code: Select all

[Rainmeter]
Update=100000

[Variables]
BGColor=0,0,0,128
FontColor=255,255,255,128
URL1=http://www.sportingnews.com/mlb/standings
LineHeight=17

[MeasureGetInfo1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=#URL1#
RegExp="(?siU)y-<a href="http://www.sportingnews.com/mlb/team/10/new-york-yankees">(.*)</a>.*<td>(.*)</td>.*<td>(.*)

</td>.*<td>(.*)</td>.*<td>(.*)</td>.*<td>(.*)</td>.*<td>(.*)</td>.*<td>(.*)</td>.*<td>(.*)</td>.*<td>(.*)</td>.*<td>

(.*)</td>.*<td>(.*)</td>"
UpdateRate=3600
StringIndex=1

[MeasureGetInfo2]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureGetInfo1]
StringIndex=2

[MeasureGetInfo3]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureGetInfo1]
StringIndex=3

[MeasureGetInfo4]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureGetInfo1]
StringIndex=4

[MeasureGetInfo5]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureGetInfo1]
StringIndex=5

[MeasureGetInfo6]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureGetInfo1]
StringIndex=6

[MeasureGetInfo7]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureGetInfo1]
StringIndex=7

[MeasureGetInfo8]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureGetInfo1]
StringIndex=8

[MeasureGetInfo9]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureGetInfo1]
StringIndex=9

[MeasureGetInfo10]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureGetInfo1]
StringIndex=10

[MeasureGetInfo11]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureGetInfo1]
StringIndex=11

[MeasureGetInfo12]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureGetInfo1]
StringIndex=12

[Background]
Meter=Image
SolidColor=#BGColor#
W=400
H=200

[MeterTextOutput1]
Meter=String
MeasureName=MeasureGetInfo1
X=5
Y=5
W=390
H=#LineHeight#
ClipString=1
FontColor=#FontColor#

[MeterTextOutput2]
Meter=String
MeasureName=MeasureGetInfo2
X=5
Y=5
W=390
H=#LineHeight#
ClipString=1
FontColor=#FontColor#

[MeterTextOutput3]
Meter=String
MeasureName=MeasureGetInfo3
X=5
Y=5
W=390
H=#LineHeight#
ClipString=1
FontColor=#FontColor#

[MeterTextOutput4]
Meter=String
MeasureName=MeasureGetInfo4
X=5
Y=5
W=390
H=#LineHeight#
ClipString=1
FontColor=#FontColor#

[MeterTextOutput5]
Meter=String
MeasureName=MeasureGetInfo5
X=5
Y=5
W=390
H=#LineHeight#
ClipString=1
FontColor=#FontColor#

[MeterTextOutput6]
Meter=String
MeasureName=MeasureGetInfo6
X=5
Y=5
W=390
ClipString=1
H=#LineHeight#
FontColor=#FontColor#

[MeterTextOutput7]
Meter=String
MeasureName=MeasureGetInfo7
X=5
Y=5
W=390
H=#LineHeight#
ClipString=1
FontColor=#FontColor#

[MeterTextOutput8]
Meter=String
MeasureName=MeasureGetInfo8
X=5
Y=5
W=390
H=#LineHeight#
ClipString=1
FontColor=#FontColor#

[MeterTextOutput9]
Meter=String
MeasureName=MeasureGetInfo9
X=5
Y=5
W=390
H=#LineHeight#
ClipString=1
FontColor=#FontColor#

[MeterTextOutput10]
Meter=String
MeasureName=MeasureGetInfo10
X=5
Y=5
W=390
H=#LineHeight#
ClipString=1
FontColor=#FontColor#

[MeterTextOutput11]
Meter=String
MeasureName=MeasureGetInfo11
X=5
Y=5
W=390
H=#LineHeight#
ClipString=1
FontColor=#FontColor#

[MeterTextOutput12]
Meter=String
MeasureName=MeasureGetInfo12
X=5
Y=5
W=390
H=#LineHeight#
ClipString=1
FontColor=#FontColor#
Wim
Posts: 69
Joined: September 22nd, 2010, 8:30 pm

Re: Help with RegExp expression

Post by Wim »

I tested your RegExp in RainRegExp and it works fine

I got this output

01=> NY Yankees
02=> 95
03=> 67
04=> .590
05=> 1
06=> 52-29
07=> 43-38
08=> 38-34
09=> 23-13
10=> 23-13
11=> Lost 2
12=> 3-7

Nothing wrong with it, it seems

You are specifically referring to the RegExp as being the problem. That does not seem to be the case.

8-)
Wim

==========================================================================

I've looked at the rest of the code.

The problem is the update rate

At the top of your file you've got

Code: Select all

[Rainmeter]
Update=100000
That means that on refresh your skin remains blank for a 100 seconds. That's a little long.

I copied your code and ran it on my computer. I made (only) two changes

I changed the update rate to: Update=1000
I changed the positioning of the meters (textoutput2 to textoutput12) into: Y=15r

It works fine

Here's the complete code

Code: Select all

[Rainmeter]
;Update=100000
Update=1000

[Variables]

BGColor=0,0,0,128
FontColor=255,255,255,128
LineHeight=17

URL1=http://www.sportingnews.com/mlb/standings
RegExp="(?siU)y-<a href="http://www.sportingnews.com/mlb/team/10/new-york-yankees">(.*)</a>.*</td>.*<td>(.*)</td>.*<td>(.*)</td>.*<td>(.*)</td>.*<td>(.*)</td>.*<td>(.*)</td>.*<td>(.*)</td>.*<td>(.*)</td>.*<td>(.*)</td>.*<td>(.*)</td>.*<td>(.*)</td>.*<td>(.*)</td>"

[MeasureGetInfo1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=#URL1#
RegExp=#RegExp#
UpdateRate=3600
StringIndex=1
Debug=1

[MeasureGetInfo2]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureGetInfo1]
StringIndex=2

[MeasureGetInfo3]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureGetInfo1]
StringIndex=3

[MeasureGetInfo4]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureGetInfo1]
StringIndex=4

[MeasureGetInfo5]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureGetInfo1]
StringIndex=5

[MeasureGetInfo6]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureGetInfo1]
StringIndex=6

[MeasureGetInfo7]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureGetInfo1]
StringIndex=7

[MeasureGetInfo8]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureGetInfo1]
StringIndex=8

[MeasureGetInfo9]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureGetInfo1]
StringIndex=9

[MeasureGetInfo10]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureGetInfo1]
StringIndex=10

[MeasureGetInfo11]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureGetInfo1]
StringIndex=11

[MeasureGetInfo12]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureGetInfo1]
StringIndex=12

[Background]
Meter=Image
SolidColor=#BGColor#
W=400
H=200

[MeterTextOutput1]
Meter=String
MeasureName=MeasureGetInfo1
X=5
Y=5
W=390
H=#LineHeight#
ClipString=1
FontColor=#FontColor#

[MeterTextOutput2]
Meter=String
MeasureName=MeasureGetInfo2
X=5
;Y=5
Y=15r
W=390
H=#LineHeight#
ClipString=1
FontColor=#FontColor#

[MeterTextOutput3]
Meter=String
MeasureName=MeasureGetInfo3
X=5
;Y=5
Y=15r
W=390
H=#LineHeight#
ClipString=1
FontColor=#FontColor#

[MeterTextOutput4]
Meter=String
MeasureName=MeasureGetInfo4
X=5
;Y=5
Y=15r
W=390
H=#LineHeight#
ClipString=1
FontColor=#FontColor#

[MeterTextOutput5]
Meter=String
MeasureName=MeasureGetInfo5
X=5
;Y=5
Y=15r
W=390
H=#LineHeight#
ClipString=1
FontColor=#FontColor#

[MeterTextOutput6]
Meter=String
MeasureName=MeasureGetInfo6
X=5
;Y=5
Y=15r
W=390
ClipString=1
H=#LineHeight#
FontColor=#FontColor#

[MeterTextOutput7]
Meter=String
MeasureName=MeasureGetInfo7
X=5
;Y=5
Y=15r
W=390
H=#LineHeight#
ClipString=1
FontColor=#FontColor#

[MeterTextOutput8]
Meter=String
MeasureName=MeasureGetInfo8
X=5
;Y=5
Y=15r
W=390
H=#LineHeight#
ClipString=1
FontColor=#FontColor#

[MeterTextOutput9]
Meter=String
MeasureName=MeasureGetInfo9
X=5
;Y=5
Y=15r
W=390
H=#LineHeight#
ClipString=1
FontColor=#FontColor#

[MeterTextOutput10]
Meter=String
MeasureName=MeasureGetInfo10
X=5
;Y=5
Y=15r
W=390
H=#LineHeight#
ClipString=1
FontColor=#FontColor#

[MeterTextOutput11]
Meter=String
MeasureName=MeasureGetInfo11
X=5
;Y=5
Y=15r
W=390
H=#LineHeight#
ClipString=1
FontColor=#FontColor#

[MeterTextOutput12]
Meter=String
MeasureName=MeasureGetInfo12
X=5
;Y=5
Y=15r
W=390
H=#LineHeight#
ClipString=1
FontColor=#FontColor#

Wim
VoodooSin
Posts: 8
Joined: October 14th, 2010, 8:30 pm

Re: Help with RegExp expression

Post by VoodooSin »

Thanks, works great. I knew the Y values would be wrong, but I was just looking to verify it was downloading ANYTHING, so a jumble of letters would have been ok. :)

And part of my problem was that somehow I created a duplicate of the ini file in the Skins folder, and was saving to that one while running the one that WAS in the correct folder. Being beaten by Notepad is a very sad thing... :Embarrassed:

Thanks again for the help, and for making me aware of RainRegExp!
Wim
Posts: 69
Joined: September 22nd, 2010, 8:30 pm

Re: Help with RegExp expression

Post by Wim »

Being beaten by Notepad is a very sad thing...
Hihihihihihi........

If it's any consolation: I've done worse at times....

...... From Our Mistakes We Shall Learn .......

:D
Wim
VoodooSin
Posts: 8
Joined: October 14th, 2010, 8:30 pm

Re: Help with RegExp expression

Post by VoodooSin »

Okay, one more question on this....

I followed the model on the WebParser info page on how to display a image from a website. I'm fairly certain these are not relative paths, so I ignored the modifications on the Tip/Tricks page. Basically now that I have the stats sections working, I'd like to display the team logo next to the stats. What I have now is below, and it isn't working....help!

EDIT: Almost forget, the rest of the code is essentially the same as up above

Code: Select all

[MeasureDLTeamLogo]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=1800
Url=#URL1#
RegExp="(?siU)<a href="http://www.sportingnews.com/mlb/team/16/chicago-cubs"><img alt="" src="http://st.snimg.com/image/mlb/logos/(.*)" />"
FinishAction=!RainmeterRedraw
StringIndex=50
Download=1

[MeterDisplayTeamLogo]
Meter=IMAGE
MeasureName=MeasureDLTeamLogo
X=430
Y=5
Wim
Posts: 69
Joined: September 22nd, 2010, 8:30 pm

Re: Help with RegExp expression

Post by Wim »

It's a little unfortunate you didn't post the complete code; I would have understood the purpose of

Code: Select all

StringIndex=50
??

The rest of the code seems to be ok.

--------------------------------------------------------------------------------------------------------------------------------------------------

I tested your Regexp again in RainRegExp and it's indeed not working.

I changed it a little:

RegExp="(?siU).*<a href="http://www.sportingnews.com/mlb/team/16/chicago-cubs">.*<img alt="" src="http://st.snimg.com/image/mlb/logos/(.*)" />.*</tr>.*"

It returns:

01=> 16_medium.png

--------------------------------------------------------------------------------------------------------------------------------------------------

The problem was:

You left out the .* between the tags. The .* means that RegExp will ignore anything in between those tags. Don't forget that there are often whitespaces, tabs and the like between tags in an HTML file. Your RegExp will ignore this when you add the .* in between the tags. A RegEx may fail if you don't. The .* at the beginning and the end are not required. This will therefore also work:

RegExp="(?siU)<a href="http://www.sportingnews.com/mlb/team/16/chicago-cubs">.*<img alt="" src="http://st.snimg.com/image/mlb/logos/(.*)" />.*</tr>"

--------------------------------------------------------------------------------------------------------------------------------------------------

By the way: Webparser needs a valid URL to find and download a file. Just returning the filename in a measure is not going to get you very far. You could also get the entire URL returned with this:

RegExp="(?siU).*<a href="http://www.sportingnews.com/mlb/team/16/chicago-cubs">.*<img alt="" src="(.*)" />.*</tr>.*"

It returns

01=> http://st.snimg.com/image/mlb/logos/16_medium.png

--------------------------------------------------------------------------------------------------------------------------------------------------

You can add it to your original RegExp:

RegExp="(?siU).*<a href="http://www.sportingnews.com/mlb/team/16/chicago-cubs">.*<img alt="" src="(.*)" />.*<a href="http://www.sportingnews.com/mlb/team/16/chicago-cubs">(.*)</a>.*</td>.*<td>(.*)</td>.*<td>(.*)</td>.*<td>(.*)</td>.*<td>(.*)</td>.*<td>(.*)</td>.*<td>(.*)</td>.*<td>(.*)</td>.*<td>(.*)</td>.*<td>(.*)</td>.*<td>(.*)</td>.*<td>(.*)</td>.*"

It returns:

01=> http://st.snimg.com/image/mlb/logos/16_medium.png
02=> Chi Cubs
03=> 75
04=> 87
05=> .460
06=> 16
07=> 35-46
08=> 40-41
09=> 17-14
10=> 34-45
11=> 16-18
12=> Lost 1
13=> 6-4

Wim
VoodooSin
Posts: 8
Joined: October 14th, 2010, 8:30 pm

Re: Help with RegExp expression

Post by VoodooSin »

Thank you so much, works beautifully...And I had the string index at 50 because I had the other parsed values, and I didn't want the icon to overwrite the team name. Not even sure if it would be an issue, but figured it wouldn't hurt to be cautious. :)
Wim
Posts: 69
Joined: September 22nd, 2010, 8:30 pm

Re: Help with RegExp expression

Post by Wim »

:D
Wim