I want to also catch everything on the same line of XYZ.
You can say that explicitly: s/ABC(.*?)XYZ\N*\n/\[DATA\]\n/s will produce your desired output. (Note \N was added in 5.12, for older versions you can say e.g. [^\n].)
Minor edits shortly after posting.
In reply to Re: Replacing between patterns
by haukex
in thread Replacing between patterns
by ovedpo15
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |