It is currently May 6th, 2024, 7:19 pm

Put spaces in a numerical value using RegExpSubstitute

Get help with creating, editing & fixing problems with skins
User avatar
Mordasius
Posts: 1173
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Put spaces in a numerical value using RegExpSubstitute

Post by Mordasius »

I have the measure:

Code: Select all

[mPing]
Measure=Plugin
Plugin=Plugins\PingPlugin
DestAddress=#PingAddress#
that returns a number like 346. What I'd like to do is to use RegExpSubstitute=1 and Substitute=????? to return a string with two spaces between each digit so that 346 becomes "3 4 6". This is so that I can use an image meter to make each digit appear in a separate 'window'. Like [3][4][6] or [0][3][4][6] when the substituted value is right justified.

So I have two questions: 1) Does RegExpSubstitute work with PingPlugin; and, 2) if so what do I use for Substitute=
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: Put spaces in a numerical value using RegExpSubstitute

Post by moshi »

there might be smarter methods, but this is mine:

Code: Select all

RegExpSubstitute=1
Substitute="^(.*)$":"ping\1ping","^ping(.)(.)(.)(.)(.)ping$":"\1  \2  \3  \4  \5","^ping(.)(.)(.)(.)ping$":"\1  \2  \3  \4","^ping(.)(.)(.)ping$":"\1  \2  \3","^ping(.)(.)ping$":"\1  \2","ping":""
Last edited by moshi on November 15th, 2012, 3:28 pm, edited 1 time in total.
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: Put spaces in a numerical value using RegExpSubstitute

Post by moshi »

actually there are smarter methods :rofl:

Code: Select all

RegExpSubstitute=1
Substitute="(.)":"\1  "
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: Put spaces in a numerical value using RegExpSubstitute

Post by moshi »

and remove the last two spaces:

Code: Select all

RegExpSubstitute=1
Substitute="(.)":"\1  ","^(.*)..$":"\1"
User avatar
Mordasius
Posts: 1173
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: Put spaces in a numerical value using RegExpSubstitute

Post by Mordasius »

Brilliant moshi. You saved me hours and hours playing around with the Substitute=

Many thanks :thumbup:

I guess I'll now have to spent the next few hours working out how it works... :???:
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: Put spaces in a numerical value using RegExpSubstitute

Post by moshi »

Mordasius wrote:
I guess I'll now have to spent the next few hours working out how it works... :???:
try the offline version of RegExr http://www.gskinner.com/RegExr/desktop/
the examples in it are great.
User avatar
Mordasius
Posts: 1173
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: Put spaces in a numerical value using RegExpSubstitute

Post by Mordasius »

I've tried working out RegExp's on that site before but find it easier to work with stuff that works in JSMorley's Rainmeter Regular Expression tester

Update: Actually I'd only ever used the online version of RegExr and could never work out if the high lag I get was affecting the results. The offline version you posted a link to is better and you're right, the 'samples' screen is very useful.