Text Manipulation Actions: regex behaving unexpectedly


New member
Hi there! I created a Macro that reads out information parsed from a JSON request to a website. It works as expected, except for one Action that I can't seem to get to work. I'm trying to get it to replace leading zeros in an HH:MM:SS time with the word "oh" only where the leading zero isn't in the hour. For example, "09 15 01" becomes "9 15 oh 1". According to Regex 101 the bolded expression works to identify only the desired leading zero: \d\d.(0)]\d

Here's a screenshot:


When MD implements this expression, it works right up until the replacement, but the rest of the numbers are lost, as if it's just replacing everything described in the regex expression, not just replacing the capturing group. So the above example becomes "09 oh". I can't tell how MacroDroid is replacing strings from any of the support docs I can find. How can I get the Text Manipulation Action to only replace the string captured by the expression, and not the entire expression?


Well-known member
Try Regex:
(\d\d)[: ]0(\d)
and replacement text:
$1 oh $2

The $n says "output the incoming matching group #n". Note that Regex101 allows you to test substitutions as well as matching; click the "Substitution" link in the left navigation area.


New member
Thanks! I didn't even realize that substitutions were part of Regex101, but I guess it makes a lot of sense that it is, and I should have looked more carefully. I fiddled around a bit more with varying your suggestion slightly, and this ended up working:

EXPRESSION: (\d.)([0])(\d) SUBSTITION: $1 oh $3

Again -- thanks so much!
Last edited:
  • Like
Reactions: RSF