balala wrote: ↑November 14th, 2019, 7:24 pm
Unfortunately it seems this code doesn't have set a MinValue option onto the [DoIt] measure. The code as it is posted, cuts the beginning of the numeric value, if it's longer.
Please check and fix your code.
My understanding is this is supposed to have a fixed max length on the numbers, so I intentionally made the regex to do it that way. It isn't a bug, it's a feature.
But if you really want a one-size fits all, here's a skin that will force a minimum length on numbers both before and after the decimal place without culling any numbers on either side, with separately assigned minimum lengths. Works whether you have decimal places or not. Works with arbitrary numbers of zeroes, decimal places and trailing non-numerical characters.
If you WANT a forced maximum length then in the third and sixth substitutes change the 0* to .* that's all it is. I literally intentionally made it cull the beginning because that's what it was supposed to do. That was literally the "fix".
This one has TWO references to the parent measure in the substitutes. One in the third substitute, one in the sixth. Make sure you change both of them to match the parent measure name.
MinValue assigns a minimum length to the pre-decimal places. MaxValue assigns a minimum length to the post-decimal places.
Here's your one size fits all measure.
Here's a video of it. I didn't showcase it but removing the decimal places entirely doesn't break anything.
UPDATE: FIXED A BUG, IF YOU USED THIS BEFORE SEEING THIS MESSAGE USE THE NEW REGEX INSTEAD.
UPDATE2: I REALIZED IM STUPID AND PUT THE DECIMAL ZEROES AT THE FRONT INSTEAD OF BACK HOLD UP I FIX.
UPDATE3: FIX: https://forum.rainmeter.net/viewtopic.php?f=5&t=33948&p=167868#p167868
Code: Select all
[Rainmeter]
Update = -1
[DoIt]
Measure = String
String = 2342.31534534gb
RegExpSubstitute = 1
MinValue = 1
MaxValue = 2
; The first substitute grabs the entire string and adds zeroes to the front
; The second substitute grabs the leading zeroes and duplicates them several times
; to ensure we have enough leading zeroes for all use cases
; Then finally the third substitute removes all but the last X digits
; Where X is the MinValue on this measure
; Then we do the exact same process over again for the numbers after the decimal place
Substitute = "(^[0-9]*)" : "0000000\1", "^(0*)(0.*)" : "\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\2", "0*([0-9]{[DoIt:MinValue]}.*)" : "\1", "\.([0-9]*)" : ".0000000\1", "(.*\.)([0]*)(0.*)" : "\1\2\2\2\2\2\2\2\2\2\2\2\2\2\2\2\2\2\2\2\2\2\2\3", "(^.*\.)0*([0-9]{[DoIt:MaxValue]}.*)" : "\1\2"
[ShowIt]
Meter = String
Text = [DoIt]
FontSize = 15
SolidColor = 0,0,0,1