It is currently April 25th, 2024, 5:42 pm

Help with RegEx please :)

Get help with creating, editing & fixing problems with skins
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Help with RegEx please :)

Post by sl23 »

Basically, I'm trying to capture the FreeDiskSpace and add a B at the end. And if the FreeDiskSpace is 0.00 B then show the text. I don't know anything about RegEx other than what's below!

Code: Select all

[m1Free]
Measure=FreeDiskSpace
Drive=#Disk1#:
RegExpSubstitute=1
Substitute="^(.+)$":"^(.+)$ B";"0.00 B":"No Drive"
Thanks :thumbup:
- MuLab -
User avatar
CodeCode
Posts: 1366
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Help with RegEx please :)

Post by CodeCode »

This is really all you need:

Code: Select all


[MeasureFreeDisk]
Measure=FreeDiskSpace
Drive=#DriveLetter#:
Substitute="G":"GB"

[MeterDrive]
Meter=String
MeasureName=MeasureFreeDisk
...
AntiAlias=1
AutoScale=1
Text=
...
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2605
Joined: March 23rd, 2015, 5:26 pm

Re: Help with RegEx please :)

Post by SilverAzide »

sl23 wrote: August 7th, 2021, 4:03 pm Basically, I'm trying to capture the FreeDiskSpace and add a B at the end. And if the FreeDiskSpace is 0.00 B then show the text. I don't know anything about RegEx other than what's below!
I'm just guessing since I didn't try it, but I think you are pretty close... the catch is that the measure returns the number of bytes (an integer), not a decimal value. So you'd need to use something like Substitute="^(.+)$":"\1 B";"0 B":"No Drive".

This scheme isn't really going to work unless you really do want to show the disk space value in bytes. If you want megabytes, gigabytes, etc., then you'll need a different approach. Let the meter control the numeric scaling, and add additional measures to handle the case where the bytes is 0.
Gadgets Wiki GitHub More Gadgets...
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Help with RegEx please :)

Post by sl23 »

Thanks for the help, but that doesn't work if the drive is 1TB or more and still doesn't change the 0.00 to No Drive.

Code: Select all

[m1Free]
Measure=FreeDiskSpace
Drive=#Disk1#:
RegExpSubstitute=1
Substitute="G":"GB";"0.00":"No Drive"

[1Free]
Meter=String
MeterStyle=sAllText | sHighlight
MeasureName=m1Free
MeasureName2=m1Total
StringAlign=Left
NumOfDecimals=2
AutoScale=1
Text=%1
ToolTipText="Size: %2B"
InlineSetting=Size | 8
InlinePattern=^.+ (.+)$
X=65
Y=7
- MuLab -
User avatar
SilverAzide
Rainmeter Sage
Posts: 2605
Joined: March 23rd, 2015, 5:26 pm

Re: Help with RegEx please :)

Post by SilverAzide »

sl23 wrote: August 7th, 2021, 4:27 pm Thanks for the help, but that doesn't work if the drive is 1TB or more and still doesn't change the 0.00 to No Drive.
See my post above. The FreeDiskSpace measure does not return 0.00. It returns an integer value.
Gadgets Wiki GitHub More Gadgets...
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Help with RegEx please :)

Post by sl23 »

Sorry, I just saw it...
SilverAzide wrote: August 7th, 2021, 4:26 pm I'm just guessing since I didn't try it, but I think you are pretty close... the catch is that the measure returns the number of bytes (an integer), not a decimal value. So you'd need to use something like Substitute="^(.+)$":"/1 B";"0 B":"No Drive".

This scheme isn't really going to work unless you really do want to show the disk space value in bytes. If you want megabytes, gigabytes, etc., then you'll need a different approach. Let the meter control the numeric scaling, and add additional measures to handle the case where the bytes is 0.
Nah, just shows the RegEx and a B after it lol : ^(.+)$ B :-(

EDIT: Now it shows /1 B
Last edited by sl23 on August 7th, 2021, 4:33 pm, edited 1 time in total.
- MuLab -
User avatar
SilverAzide
Rainmeter Sage
Posts: 2605
Joined: March 23rd, 2015, 5:26 pm

Re: Help with RegEx please :)

Post by SilverAzide »

sl23 wrote: August 7th, 2021, 4:31 pm Sorry, I just saw it...

Nah, just shows the RegEx and a B after it lol : ^(.+)$ B :-(
I had a typo and fixed it... Try again. You need "\1"...
Gadgets Wiki GitHub More Gadgets...
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Help with RegEx please :)

Post by sl23 »

:confused: EDIT: Now it shows /1 B
- MuLab -
User avatar
Yincognito
Rainmeter Sage
Posts: 7164
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Help with RegEx please :)

Post by Yincognito »

sl23 wrote: August 7th, 2021, 4:33 pm :confused: EDIT: Now it shows /1 B
Substitute="^$":"0","^(.+)$":"\1 B","^0 B$":"No Drive"
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Help with RegEx please :)

Post by sl23 »

Oops! Wrong slash :oops:
Substitute="^(.+)$":"\1B";"0B":"No Drive"
Close, but now I get 0.00 B displayed. So I tried 0B, 0 B, 0.00B and 0.00 B, still no luck! :?
- MuLab -