WordPress at a glance
function is not described

PO::match_begin_and_end_newlines() public WP 1.0

{} It's a method of the class: PO{}

No Hooks.

Return

null. Null. Nothing.

Usage

$result = PO::match_begin_and_end_newlines( $translation, $original );
$translation (required)
-
$original (required)
-

Code of PO::match_begin_and_end_newlines() WP 5.7

<?php
public static function match_begin_and_end_newlines( $translation, $original ) {
	if ( '' === $translation ) {
		return $translation;
	}

	$original_begin    = "\n" === substr( $original, 0, 1 );
	$original_end      = "\n" === substr( $original, -1 );
	$translation_begin = "\n" === substr( $translation, 0, 1 );
	$translation_end   = "\n" === substr( $translation, -1 );

	if ( $original_begin ) {
		if ( ! $translation_begin ) {
			$translation = "\n" . $translation;
		}
	} elseif ( $translation_begin ) {
		$translation = ltrim( $translation, "\n" );
	}

	if ( $original_end ) {
		if ( ! $translation_end ) {
			$translation .= "\n";
		}
	} elseif ( $translation_end ) {
		$translation = rtrim( $translation, "\n" );
	}

	return $translation;
}