#!/usr/bin/perl # http://perlmonks.org/?node_id=1176579 use strict; use warnings; $_ = do { local $/; }; print map s/\s+/ /gr =~ s/\s*$/\n/gr, /(\b\d+:\d+\b(?:(?!\b\d+:\d).)*)/gs; __DATA__ 3:3 And he shall offer of the sacrifice of the peace offering an offering made by fire unto the LORD; the fat that covereth the inwards, and all the fat that is upon the inwards, 3:4 And the two kidneys, and the fat that is on them, which is by the flanks, and the caul above the liver, with the kidneys, it shall he take away. 3:5 And Aaron's sons shall burn it on the altar upon the burnt sacrifice, which is upon the wood that is on the fire: it is an offering made by fire, of a sweet savour unto the LORD.