See also Comby, which is a language-aware sed that Just Works for many common use cases. It matches named :[holes] in your code (think capture groups) and can perform additional logic on the matches (think Rust's conditional match arms).
https://comby.dev/