SmartThings Community

Groovy String Replace


(JIm) #1

I have a string being returned from a device that has a day in it which could be any day in the form of SUN OR MON OR TUE, etc. I want to replace that with the complete day word, ie SUNDAY OR MONDAY, etc. Here is what I did.

s1=s.replaceAll(“SUN”,“SUNDAY”)
s2=s1.replaceAll(“MON”,“MONDAY”)
And so on.

Is there a way to do this in one statement instead of 7?

Thanks.


#2

Try:

s1=s.replaceAll(“SUN”,“SUNDAY”).replaceAll(“MON”,“MONDAY”)