Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • Uh.. that's exactly what sed does. sed --in-place 's/expr/replacement/' /path/to/file Commented May 15, 2016 at 19:17
  • @DopeGhoti Are you certain you read my question properly? I'm pretty sure sed doesn't support multiline regex with such simple syntax and as far as I know it doesn't support lookahead or lookbehind at all. Commented May 15, 2016 at 19:23
  • There's a snippet to load the whole file into sed's pattern space: sed -e :a -e '$!{N;b a}' -e other_commands... . This way you can use multiline regex Commented May 15, 2016 at 20:51
  • ssed (super sed) supports perl regex Commented May 15, 2016 at 20:55
  • @basin It's less of a problem of availability of perl regex and more of a problem with "search and replace" using a more complex regex that's supposed to match (and replace with) multiline strings. As I stated in my question perl itself cannot do this without some added programming logic dealing with the multiline regex which makes the syntax more complicated. Commented May 16, 2016 at 5:37