Hm... I think we can make the regexp `/(.*)\n?(.*\n)?/`, so that you won't need the conditions at all.

(Yes, I'm kind of obsessive over these minutiae.)