regexperlrainmeter

Regex returning last character of string?


'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!


Solution

  • 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.