| 12345678910111213 |
- /**
- * Normalizes a string to replace non-alphanumeric and diacritical marks with
- * plain equivalents.
- * Based on https://stackoverflow.com/a/37511463/772859
- */
- export function normalizeString(input: string, spaceReplacer = ' '): string {
- return input
- .normalize('NFD')
- .replace(/[\u0300-\u036f]/g, '')
- .toLowerCase()
- .replace(/[!"£$%^&*()+[\]{};:@#~?\\/,|><`¬]/g, '')
- .replace(/\s+/g, spaceReplacer);
- }
|