Q: How many backslashes are required for backrefs in regex_replace?
A: It depends. Normally two for YAML, but one if using a literal block scalar.
If a number comes immediately after a backref, use \g<$n>.
PLAY [localhost] *******************************************************************************************************************************************************************************************
TASK [debug] ***********************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "abc123"
}
TASK [debug] ***********************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "abc123"
}
TASK [debug] ***********************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "123456"
}
PLAY RECAP *************************************************************************************************************************************************************************************************
localhost : ok=3 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0