Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 1x 10x 10x 10x 10x 10x 10x 10x | export const sanitizeName = (str: string) => str // 1) replace any sequence of non-alphanumeric characters (except spaces) with a space .replace(/[^a-zA-Z0-9\s]+/g, " ") // 2) replace multiple spaces with a single space .replace(/\s+/g, " ") // 3) insert space between letter followed by digits (e.g. kitchen1 → kitchen 1) .replace(/([a-zA-Z])(\d+)/g, "$1 $2") // 4) lowercase all to normalize case before capitalization .toLowerCase() // 5) capitalize first letter of each word .replace(/\b\w/g, (c) => c.toUpperCase()) // 6) trim trailing spaces .trim(); |