in reply to Multiline regex for moving lines?

You can do it with regexes, and have been shown several ways of doing it, but regexes is not the best tool to do that. Just as you can drive a nail into a piece of wood by hammering it with the handle of a screwdriver.

Splitting your input into an array of lines seems more natural, more flexible if your rules change and would scale better if your input grows larger. So why not using split?