It is currently May 6th, 2024, 2:25 am

[Bug] Endless Loop using RegExpSubstitute

Report bugs with the Rainmeter application and suggest features.
User avatar
Brian
Developer
Posts: 2689
Joined: November 24th, 2011, 1:42 am
Location: Utah

[Bug] Endless Loop using RegExpSubstitute

Post by Brian »

I'm not sure how others do this, but I often use Substitute to define a default value when using the WebParser plugin.
For example:

Code: Select all

[Background]
Meter=Image
X=0
Y=0
W=100
H=100
SolidColor=0,0,0,255

[Website]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=http://rainmeter.net/cms
UpdateRate=3600
RegExp="(?siU)<h2>Download</h2>.*(?(?=.*<b>2.1</b>).*<b>(.*)</b>)"

[Version]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[Website]
Substitute="":"Not Available."
StringIndex=1

[Text]
Meter=String
MeasureName=Version
X=0
Y=0
FontColor=255,255,255,255
This will display "Not Available." as it should since "2.1" is not found on the website. However, if you use RegExpSubstitute=1 in the [Version] measure, Rainmeter just freezes. The reason I feel this is a bug is because in certain skins, I substitute out some HTML tags, and its easier to use regular expressions to substitute them out for something else, yet I would still like to define a default value.

-Brian
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Bug] Endless Loop using RegExpSubstitute

Post by jsmorley »

Certainly a bug... Even if Regular Expression doesn't support Substitute="":"Not Available." written that way, it shouldn't crash Rainmeter.

[Website]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=http://rainmeter.net/cms
UpdateRate=3600
RegExp="(?siU)<h2>Download</h2>.*(?(?=.*<b>2.2</b>).*<b>(.*)</b>)"

[Version]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[Website]
;RegExpSubstitute=1
Substitute="":"Not Available."
StringIndex=1

Remove the comment indication from ;RegExpSubstitute=1 and Rainmeter crashes and burns.
User avatar
Brian
Developer
Posts: 2689
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: [Bug] Endless Loop using RegExpSubstitute

Post by Brian »

Yeah, its not a huge issue, but a issue none the less.

-Brian
User avatar
Brian
Developer
Posts: 2689
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: [Bug] Endless Loop using RegExpSubstitute

Post by Brian »

I figured out a way to make this work. Instead of using Substitute="":"Not Available." use Substitute="^$":"Not Available."

In regular expressions, the "^" means start of the string, and the "$" means the end of the string. So in essence, it's an empty string.

-Brian