Hi. I have a few webparser measures which return a lower-case string, which I would like to be upper-case (eg. for province code, measure returns "bc" which I would like to be "BC"). First thought was to use a regex substitution, but searching the forums, I see that \U doesn't work here. Is there another way?
Alternatively, it could be done using an Inline Option when displayed in a string meter. The issue here is that I wish to display it in a tooltip, and don't think that the Inline Option applies to the tooltip?
It is currently October 23rd, 2024, 11:33 pm
Case Conversion: measure or meter
-
- Posts: 244
- Joined: April 10th, 2014, 12:31 am
- Location: Canada
-
- Developer
- Posts: 22886
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Case Conversion: measure or meter
I think the best way is a very simple Lua function:qwerky wrote: ↑Yesterday, 9:07 pm Hi. I have a few webparser measures which return a lower-case string, which I would like to be upper-case (eg. for province code, measure returns "bc" which I would like to be "BC"). First thought was to use a regex substitution, but searching the forums, I see that \U doesn't work here. Is there another way?
Alternatively, it could be done using an Inline Option when displayed in a string meter. The issue here is that I wish to display it in a tooltip, and don't think that the Inline Option applies to the tooltip?
https://docs.rainmeter.net/manual/lua-scripting/inline-lua/
Test.lua:
Code: Select all
function Upper(inString)
return string.upper(inString)
end
Code: Select all
[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
[Variables]
[Lua]
Measure=Script
ScriptFile=Test.lua
Disabled=1
[MeasureString]
Measure=String
String=bc
[MeterString]
Meter=String
Text=[&Lua:Upper('[&MeasureString]')]
FontSize=16
SolidColor=0,0,0,1
FontColor=255,255,255,255
AntiAlias=1
ToolTipText=[&Lua:Upper('[&MeasureString]')]
DynamicVariables=1
You do not have the required permissions to view the files attached to this post.
-
- Rainmeter Sage
- Posts: 8551
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Case Conversion: measure or meter
Indeed, neither the Inline Case, nor the StringCase in a String meter would work for tooltips, though they would work just fine for either parts or the entire contents of the String meter itself. Regex support for \U is quite rare, and unavailable in Rainmeter as well - even regex101.com mentions that the feature is only available on their site. I believe jsmorley's advice is a very simple one to follow, especially if we're talking about tooltips, where other features that Rainmeter provides are limited.qwerky wrote: ↑Yesterday, 9:07 pm Hi. I have a few webparser measures which return a lower-case string, which I would like to be upper-case (eg. for province code, measure returns "bc" which I would like to be "BC"). First thought was to use a regex substitution, but searching the forums, I see that \U doesn't work here. Is there another way?
Alternatively, it could be done using an Inline Option when displayed in a string meter. The issue here is that I wish to display it in a tooltip, and don't think that the Inline Option applies to the tooltip?
By the way, Rainmeter does not do regex patterns (bar the \1, \2 and such references) in the 2nd part of the substitution, i.e. the one after the : symbol. I'm saying this because I've seen other applications do it (which would be where the \U part is written, if it were to be possible).
-
- Posts: 244
- Joined: April 10th, 2014, 12:31 am
- Location: Canada
-
- Posts: 244
- Joined: April 10th, 2014, 12:31 am
- Location: Canada
Re: Case Conversion: measure or meter
And thank you too for the quick response. That's good information to be aware of.Yincognito wrote: ↑Yesterday, 9:51 pm By the way, Rainmeter does not do regex patterns (bar the \1, \2 and such references) in the 2nd part of the substitution, i.e. the one after the : symbol. I'm saying this because I've seen other applications do it (which would be where the \U part is written, if it were to be possible).
-
- Rainmeter Sage
- Posts: 8551
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Case Conversion: measure or meter
Out of curiosity, how come the province codes are lower case on that site? It's almost an unwritten standard for them to be upper case, and especially if they are initials of different names (i.e. different words) ...
-
- Posts: 244
- Joined: April 10th, 2014, 12:31 am
- Location: Canada
Re: Case Conversion: measure or meter
That's a very good question! That site also has lower-case for the current station code (the airport code -- YVR, which in my experience is also usually upper-case); but on the other hand, it does have the timezone code (PDT) in upper-case. Wish I could find some better documentation for that site.Yincognito wrote: ↑Yesterday, 10:14 pm Out of curiosity, how come the province codes are lower case on that site? It's almost an unwritten standard for them to be upper case, and especially if they are initials of different names (i.e. different words) ...
BTW, I just noticed that this forum's smilies have changed. I thought there used to be a :shrug:, but maybe not.
-
- Developer
- Posts: 22886
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Case Conversion: measure or meter
So not that?
-
- Posts: 244
- Joined: April 10th, 2014, 12:31 am
- Location: Canada
-
- Developer
- Posts: 22886
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Case Conversion: measure or meter
Search around on the interwebs, and if you find a reasonably small animated gif "shrug" smiley. Attach it here and I will gladly add it.
¯\_(ツ)_/¯