if (nationalPrefixFormattingRule.length() > 0) {
// Before we do a replacement of the national prefix pattern $NP with the national prefix,
// we need to copy the rule so that subsequent replacements for different numbers have the
// appropriate national prefix.
NumberFormat numFormatCopy = new NumberFormat();
numFormatCopy.mergeFrom(numFormat);
String nationalPrefix = getMetadataForRegion(regionCode).getNationalPrefix();
if (nationalPrefix.length() > 0) {
// Replace $NP with national prefix and $FG with the first group ($1).
nationalPrefixFormattingRule =
NP_PATTERN.matcher(nationalPrefixFormattingRule).replaceFirst(nationalPrefix);