Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 1538

Help: Rainmeter Skins • Re: Leading Zeros

$
0
0
The question is already answered, but since we're at it, for additional features and flexibility as well as any pontential future readers, a one size fits all solution that should work for positive / negative and integer / fractional numbers:

Code:

RegExpSubstitute=1Substitute="^([^-]+)$":"+\1","^([^.]+)$":"\1.","([\d.]+)":"000\100","^([-+]).*(\d{3})(\.)(\d{2}).*$":"\1\2\3\4"
This adds the sign if missing (mandatory, 1st substitution), adds the decimal point if missing (mandatory, 2nd substitution), adds a sufficient number of leading / trailing zeroes (adjustable, 3rd substitution), then leaves only the desired amount of desired parts (adjustable, 4th substitution). In the replacement from the 4th substitution, \1 is the sign, \2 is the integer digits, \3 is the decimal point and \4 is the decimal digits, with either of them removable. Best used with the string value of the [measure] and DynamicVariables=1.

P.S. The sufficient number of zeroes in the replacement from the 3rd substitution must be greater than the desired amount captured in the pattern from the 4th substitution, so you could very well permanently add as many zeroes as you could possibly have, and adjust things only in the pattern and replacement from the 4th substitution afterwards.

Statistics: Posted by Yincognito — 42 minutes ago



Viewing all articles
Browse latest Browse all 1538

Trending Articles