This doesn’t seem very useful to me since you could just use \n?\z instead, which seems more obvious.

My guess is that this was provided to match the behavior in Perl as described here:

Because Perl returns a string with a newline at the end when reading a line from a file, Perl’s regex engine matches $ at the position before the line break at the end of the string even when multi-line mode is turned off. Perl also matches $ at the very end of the string, regardless of whether that character is a line break. So ^\d+$ matches 123 whether the subject string is 123 or 123\n.

Personally, I would probably avoid using this at all since it’s likely to be confused for \z.