OH3: How to transform sitemap string value to upper case?

I have a seemingly basic question, what is the best way to make the first letter(s) of an item value upper case? The “Weather Condition” values are lower-case as provided by the OpenWeatherMap API. For example: I have “clear sky” currently but would like it to show “Clear Sky”. Based on what I’ve read under the Transformations documentation I’m inclined to take the Regex approach (RegEx - Transformation Services | openHAB).

Is there a more elegant solution?

Here is the relevant block from my .sitemap:

Frame label="Weather" {
	Text item=LocalWeatherandForecast_StationName icon="house"
	Text item=LocalWeatherandForecast_Location icon="marker"
	Text item=LocalWeatherandForecast_ObservationTime icon="time"
	Text item=LocalWeatherandForecast_WeatherCondition
	Text item=LocalWeatherandForecast_OutdoorTemperature
	Text item=Sun_SunPhaseName icon="time"
	Text item=Sunrise_Time icon="sunrise" visibility=[Night_State == ON]
	Text item=Sunset_Time icon="sunset" visibility=[Night_State == OFF]
	Text item=Moon_MoonPhaseName icon="moon"
	Text item=ntp_ntp_local_string icon="time"                                                                                                                             
}

  • Platform information:
    • Hardware: armv7l/1GB RAM/32GB SD
    • OS: Openhabian (Raspbian GNU/Linux 11 (bullseye))
    • Java Runtime Environment: openjdk 11.0.16 2022-07-19
    • openHAB version: 3.3

Apply a MAP transformation in a profile, it’s a lookup table to substitute any text you like.
This would change the Item state.

If you want to keep the Item state standard (perhaps you use it in rules) then apply the transform instead in the sitemap widget label’s [state presentation] parameter

Thanks @rossko57 for the suggestions. I started down the MAP route last night but then ended up leveraging JS Transformation using this example Javascript transform example with system uptime and a function I found on Stackoverflow

/home/openhabian/conf/transform/caps.js looks like this:

(function capitalize(str){
            str = str.toLowerCase();
            return str.replace(/([^ -])([^ -]*)/gi,function(v,v1,v2){ return v1.toUpperCase()+v2; });
})(input)

The result:

Item 'LocalWeatherandForecast_WeatherCondition' changed from mist to Mist