I’m trying to create a regular expression mask to insert the time starting with seconds, minutes and finally the hour.
For example, showing 12:34:56
after typing – 6, 5, 4, 3, 2, 1
I tried creating a regular expression, but I’m not very experienced. If you can help me I would be very grateful
This is my regex that didn’t work:
function timeinvert(v) {
v = v.replace(/D/g, "");
v = v.replace(/(d)(d)/, "$2$1")
v = v.replace(/(d)(d)(d)/, "$3:$2$1")
v = v.replace(/(d)(d)(d)(d)/, "$4$3:$2$1")
v = v.replace(/(d)(d)(d)(d)(d)/, "$5:$4$3:$2$1")
v = v.replace(/(d)(d)(d)(d)(d)(d)d+?$/, "$6$5:$4$3:$2$1")
// v = v.replace(/(d{2})(d)/, "$1:$2")
// v = v.replace(/(d{2})d+?$/, "$1")
return v;
}