JSONata: $replace & /regex/

I have this regex in Home Assistant that I want to replicate in NR via JSONata:

regex_replace(find="^[0:]*",replace="")

It replaces leading 0's or :'s until no match, with null.

I have this so far which doesn't completely work:

$replace($fromMillis((msg.payload * 1000), '[H01]:[m01]:[s01]' ), /[(0+):]/, '', 3)

as it replaces just single occurrences anywhere in the string up to 3 times.

What I want is just replace from the beginning, 0 or :, until no match so that...
'00:01:10' is '1:10'
'00:10:01' is '10:15'
'01:01:01': is "1:01:01'

This seems to be working...

$replace($fromMillis((msg.payload * 1000), '[H]:[m01]:[s01]' ), /^[0:]*/, '')

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.