formatAsYouType

fun formatAsYouType(digits: String, country: Country): String(source)

Groups digits the way a user of country expects to see them, mid-typing.

Uses libphonenumber's AsYouTypeFormatter, which is the same engine the platform dialer uses, so partial input formats progressively (71 → 712 → 712 3 → 712 345 678) instead of only snapping into shape once complete.

Return

The grouped national form, or digits unchanged when the region has no metadata.

Parameters

digits

Raw digits, no separators. Anything non-digit is ignored.