in reply to Re^2: Extract Multiple Lines from the End of a multi-line string
in thread Extract Multiple Lines from the End of a multi-line string

I defined a line as either "zero or more non-newline characters followed by a newline (/.*\n/)" or "one or more non-newline characters (/.+/)". That way,

That's the same behaviour as <FH>.

If I had used /.*\n?/ instead of /.*\n|.+/, "foo\nbar\n" would have been considered to have three lines ("foo\n", "bar\n" and ""). Always be wary of patterns that can match zero characters.