I want to delete a set of lines (globally) only if the entire pattern matches.
- Line3 can have space(s) after
- Line2 and Line4 may have a space character or should be blank
- Line5, either matches
- I don't want to delete the last line of the pattern i.e.
Line5in the pattern description.
# Body - Inside Body # Summary - # Bibliography - Read this book
# Body - Inside Body # Bibliography - Read this book
Note: The provided solution works, is it possible to write it more clearly as follows:
e = '(^|\n)[#]+ .*\ \n[\t ]*\ \n-[\t ]*\ \n[\t ]*\ \n([#]+ .*|[-]+[\t ]*)\n'
Also, how can we do the provided solution for multiple occurrences of the multiline pattern?