It is currently March 29th, 2024, 12:26 pm

How to cut numbers ?

Get help with creating, editing & fixing problems with skins
User avatar
krakoukas
Posts: 71
Joined: December 11th, 2018, 5:56 pm
Location: France

How to cut numbers ?

Post by krakoukas »

Hi friends,

What is the easiest way to cut meter for this result :

27000 -> 27 000
1234567 -> 1 234 567

Thank you for your help
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to cut numbers ?

Post by balala »

krakoukas wrote: December 11th, 2018, 6:01 pm What is the easiest way to cut meter for this result :

27000 -> 27 000
1234567 -> 1 234 567
What that meter shows up? Because you have to pass the value through a measure (for example through a Calc measure), where you have to add a Substitute option, like the following:

Code: Select all

[MeasureValue]
...
RegExpSubstitute=1
Substitute="^(\d{1,3})(\d{3})$":"\1 \2","^(\d{1,3})(\d{3})(\d{3})$":"\1 \2 \3","^(\d{1,3})(\d{3})(\d{3})(\d{3})$":"\1 \2 \3 \4","^(\d{1,3})(\d{3})(\d{3})(\d{3})(\d{3})$":"\1 \2 \3 \4 \5"
The above RegExpSubstitute and Substitute options can be added to any measure, but not to meters. Doesn1t matter too much what kind of measure do you have, important is to have one, to can add somewhere these options.
If what the String meter has to show is a variable, then you have to add a (for example) a Calc measure ([MeasureValue]) and add the above RegExpSubstitute and Substitute options to that one.
If you can't handle this, please post the code you have so far.
User avatar
krakoukas
Posts: 71
Joined: December 11th, 2018, 5:56 pm
Location: France

Re: How to cut numbers ?

Post by krakoukas »

Works great with measure of course !
Thanks a lot balala for very quick & very useful regexp

Image
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to cut numbers ?

Post by balala »

krakoukas wrote: December 11th, 2018, 7:18 pm Works great with measure of course !
The only thing you have to take care, is the limit, until the substitution works well: in this case this value is 999,999,999,999,999 (15 digits). On higher values the substitution wont work. But I thing it doesn't even has to. Am I right?
User avatar
krakoukas
Posts: 71
Joined: December 11th, 2018, 5:56 pm
Location: France

Re: How to cut numbers ?

Post by krakoukas »

Right again :thumbup:
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to cut numbers ?

Post by balala »

krakoukas wrote: December 11th, 2018, 7:38 pm Right again :thumbup:
I'm glad.