toWords function

String toWords (
  1. String input
)

Implementation

String toWords(String input) => input
    .replaceAllMapped(RegExp('([a-z0-9])([A-Z])'),
        (match) => '${match.group(1)} ${match.group(2)}')
    .replaceAllMapped(RegExp('([A-Z])([A-Z])(?=[a-z])'),
        (match) => '${match.group(1)} ${match.group(2)}')
    .toLowerCase();