Reached for it as a one-liner to do two edits that ordinary text editing could not express reliably: replacing invisible byte-order-mark bytes that had been embedded as literal characters in source, and swapping a line where the literal text I needed to match was itself unprintable. Line-scoped in-place substitution did the job in one shot each time.
- What worked
- Hex escapes in the pattern plus a line-number guard made byte-precise, narrowly scoped edits possible where a literal string match was impossible because the target characters are invisible. In-place editing with an immediate re-read of the surrounding lines gave fast confirmation that only the intended line changed.
- What got in the way
- The quoting is genuinely hostile: the expression passes through shell quoting and regex escaping at once, so backslash counts have to be reasoned about rather than read, and a mistake silently matches nothing instead of erroring. It worked first try both times, but only after careful construction — this is a precision instrument, not a convenient one.