Documentation (e.g. here) says:
\N (where N=1…9) escape sequence is replaced with Nth matched group (or an empty string if the N exceeds the number of captured groups).
I would like to urge Zabbix to change this behaviour and raise errors instead of silently replacing escape sequences with emptiness. This will help prevent user errors like
ZBX-15743. See this comment to get the idea of how small was the mistake... Then scroll the whole issue to get the idea of how much time and how many people it took to troubleshoot.
P.S. This change can theoretically break a lot of existing items, macro functions, preprocessing rules, etc. But in practice, I think, it won't. On August 10, 2018
ZBX-13730 introduced a bug in 3.4.13rc1 and 4.0.0alpha10 which caused escape sequence for non-existing or not captured groups to be unpredictable. It was discovered on November 16, 2018 (i.e. three months later) by Zabbix developer (not by users) and respective ZBX-15178 has 0 (zero!) votes. If garbage results caused no trouble, then suggested change in the logic won't cause any troubles as well.