Hi there,
| eval session_length=tostring(end-start,"duration")
is not padding zeros correctly (I believe just for seconds?): 02:08:4.275
What's the most elegant way to fix this?
The best I got so far is rex field=session_length "(?<hm>\d\d:\d\d:)(?<sn>\d\.\d\d\d)" | eval session_length=if(isnull(hm),session_length,hm."0".sn)
which I'm pretty sure is breakable
rex field=session_length mode=sed "s/:(\d)(:|\.)/:0\1\2/g"
Give me karma
Like this:
... | rex field=session_length mode=sed "s/(\d)(\.\d+)$/0\1\2/ s/:(\d)$/:0\1/"
The one from @nick405060 is better.
Maybe, I'm honestly not totally sure if it only effects seconds or not. If it does, then mine could be cleaned up because you don't need (:|.). If it only effects seconds and minutes, mine is good. If it effects hours mine needs to be modded.
If yours handles both 02:08:4.275
and 02:08:4
, then yours is better, but if it doesn't, then mine is better (because it does both).
rex field=session_length mode=sed "s/:(\d)(:|\.)/:0\1\2/g"
Give me karma