It is currently April 26th, 2024, 3:02 am

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

Re: Help with RegEx please :)

Post by sl23 »

Yincognito wrote: August 7th, 2021, 4:40 pm Substitute="^$":"0","^(.+)$":"\1 B","^0 B$":"No Drive"
Thanks, but nope. I still get 0.00 B :-(

Could it be something to do with InlinePattern?
- 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:41 pm 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! :?
Please, put up your glasses, LOL. It's , and not ; ...
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
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:41 pm 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! :?
Ok, WHERE exactly do you get that? In the measure or in the meter? Cause if it's in the meter, changing the number of decimals (or scale/autoscale below?), if you have such an option, will do.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
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 »

Try this:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

---Measures---

[m1Free]
Measure=FreeDiskSpace
Drive=M:
RegExpSubstitute=1
Substitute="^$":"0","^(.+)$":"\1 B","^0 B$":"No Drive"

---Meters---

[meterDrive]
Meter=String
StringEffect=Shadow
FontEffectColor=0,0,0,50
SolidColor=47,47,47,255
FontColor=255,255,255,255
FontFace=Consolas
FontSize=16
AntiAlias=1
MeasureName=m1Free
Text=Drive: %1
DynamicVariables=1
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 »

In the meter, I think.

But that last Substitute is not being treated correctly by the InlinePattern, so I have to remove the spaces...
Substitute="^$":"0","^(.+)$":"\1B","^0B$":"No Drive"
Image 003.png
But after doing so, it still doesn't replace the value with the string. Maybe I should just leave the 0.00 GB instead?! :???:
Image 004.png
You do not have the required permissions to view the files attached to this post.
Last edited by sl23 on August 7th, 2021, 7:07 pm, edited 1 time in total.
- MuLab -
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 »

Yincognito wrote: August 7th, 2021, 4:44 pm Please, put up your glasses, LOL. It's , and not ; ...
Haha, well, I probably should wear them tbh! :oops: :lol:
- 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, 6:55 pm In the meter, I think.

But that last Substitute is not being treated correctly by the InlinePattern, so I have to remove the spaces...
Substitute="^$":"0","^(.+)$":"\1B","^0B$":"No Drive"
Image 003.png

But after doing so, it still doesn't replace the value with the string. Maybe I should just leave the 0.00 GB instead?! :???:
Image 004.png
That probably happens because you use the number value of the measure (and not the supposedly correctly modified string value of it), due to the numerical related options like NumOfDecimals or AutoScale in the meter. If you look at the log, the measure value should be fine. Is it?

P.S. I only noticed your code here now...I should put my glasses too, it seems. :lol:
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 »

I don't understand how the Meter options affect the substitution? Or isn't that what you are saying?

There are no errors in the log if that's what you mean. :)
- MuLab -
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 »

Yincognito wrote: August 7th, 2021, 7:08 pm P.S. I only noticed your code here now...I should put my glasses too, it seems. :lol:
:rolmfao: That's ok, you're one of the good guys, so I'll forgive you... this time! :p
- 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, 7:11 pm I don't understand how the Meter options affect the substitution? Or isn't that what you are saying?

There are no errors in the log if that's what you mean. :)
Yeah, don't worry, I just tested myself, no need to bother, my suspicion was true. I didn't mean that there should be errors in the log, I only meant that the STRING value of the MEASURE should be what you expect it to be, i.e. "No Drive", but because the METER is using the measure's NUMBER value (due to the numerical related options like NumOfDecimals or AutoScale), you don't get the expected result visually:
NS.jpg
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth