Regex returning last character of string?

510 Views Asked by At

'Ello, so I'm using Rainmeter and I just want to get the last character of a string using Regex. Rainmeter uses Perl regex. The string is just two characters long, it's just minutes (so just two numbers) and I need the second digit.

This is what I have for getting just the first digit.

[MeasureMinutePrefix]
Measure=Time
Format=%M
RegExpSubstitute=1
Substitute="^(.{1,1}).+$":"\1"

Thanks!

2

There are 2 best solutions below

1
On BEST ANSWER

I don't know Rainmeter, but extrapolating from your example, this should do it:

Substitute="^.*(.)$":"\1"

BTW, there's no need for {1,1} in the regexp. That's the normal meaning of any non-quantified pattern, it matches exactly once.

2
On
Substitute="^.{1}(.{1,1})$":"\1"

or

Substitute="^\d(\d)$":"\1"