in reply to Replacing between patterns

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.

Replies are listed 'Best First'.
Re^2: Replacing between patterns
by ovedpo15 (Pilgrim) on Oct 28, 2019 at 13:12 UTC
    Thanks! The old version is being supported on new versions as well?
      The old version is being supported on new versions as well?

      Yes, it is. Here's another backwards-compatible alternative: s/ABC(?s:.*?)XYZ.*/[DATA]/