Given a regular expression and a replacement string, how can I use awk to implement the following:
- if a line contains no match, does nothing;
- if a line contains more than one matches, replace the last match with the replacement string, in the sense of the last match which would be substituted by
- if a line contains exactly one match, replace the match with the replacement string.
For example, see " unexpected character '\'" in gawk