It is currently April 25th, 2024, 2:07 am

Regex help with local file parsing

Get help with creating, editing & fixing problems with skins
User avatar
Raikuga
Posts: 12
Joined: May 20th, 2010, 11:00 pm

Regex help with local file parsing

Post by Raikuga »

I want to create a dock skin that gets its information from a .txt file. However, I don't think my parsing is very good. I at first had a single line and it worked, but when I added the second line for a photoshop link, it adds the extra space where the icon should go but the icon is not there. So I'm guessing that the regex isn't working the way I intended it to be. Could someone help me with this?

Code: Select all

[Parser]
Measure=Plugin
Plugin=WebParser.dll
Url=file://#CURRENTPATH#Links.txt
RegExp="(?iU)((\w+):(.+))+"
UpdateRate=86400

;Icon style
[Icon]
PreserveAspectRatio=1
Greyscale=1
AntiAlias=1
X=10R
Y=r
W=32
H=32

[Icon1]
Measure=Plugin
Plugin=WebParser.dll
Url=[Parser]
StringIndex=2
[Link1]
Measure=Plugin
Plugin=WebParser.dll
Url=[Parser]
StringIndex=3
[Icon2]
Measure=Plugin
Plugin=WebParser.dll
Url=[Parser]
StringIndex=5
[Link2]
Measure=Plugin
Plugin=WebParser.dll
Url=[Parser]
StringIndex=6

[Dock1]
Meter=Image
MeterStyle=Icon
MeasureName=Icon1
Path=Icons
LeftMouseUpAction=!Execute [[Link1]]
[Dock2]
Meter=Image
MeterStyle=Icon
MeasureName=Icon2
Path=Icons
LeftMouseUpAction=!Execute [[Link2]]
Links.txt:

Code: Select all

Firefox:firefox.exe
Photoshop:"C:\Program Files\Adobe\Adobe Photoshop CS4 (64 Bit)\Photoshop.exe"
User avatar
Alex2539
Rainmeter Sage
Posts: 642
Joined: July 19th, 2009, 5:59 am
Location: Montreal, QC, Canada

Re: Regex help with local file parsing

Post by Alex2539 »

Unfortunately, Rainmeter handles regular expressions a little bit differently than most other applications. While normally the repetition of that pattern would have resulted in several results, Rainmeter requires each result to be explicitly searched for. Change your RegExp to something like this:

Code: Select all

Regexp=(?siU)(\w+):(.+)\n(\w+):(.+)
That will return two programs' names and paths. To add more items, you will need to expand the RegExp by adding the "(\w+):(.+)\n" pattern at the end.
ImageImageImageImage
User avatar
Raikuga
Posts: 12
Joined: May 20th, 2010, 11:00 pm

Re: Regex help with local file parsing

Post by Raikuga »

Well, I got it to work using a dollar sign at the end. But now my problem is, it's giving me error messages when trying to run notepad and paint! When I give it a command (basically !Execute ["mspaint.exe"]) Paint gives me an error:
C:\Program Files\Rainmeter\.png contains an invalid path.
I didn't give it any parameters to open with, so why is it giving this error?

Notepad opens unlike paint, but it still gives an error message:
The filename, directory name, or volume label syntax is incorrect.
This is probably referring to the same link as Paint was.

MBAM (Malwarebytes) runs just fine, along with Firefox and Photoshop.

Now, Links.txt looks like:

Code: Select all

Firefox:"firefox.exe"
Photoshop:"C:\Program Files\Adobe\Adobe Photoshop CS4 (64 Bit)\Photoshop.exe"
Paint:"mspaint.exe"
Notepad:"notepad.exe"
MBAM:"mbam.exe"