UNPKG

ts-prime

Version:

A utility library for JavaScript and Typescript.

18 lines (17 loc) 477 B
/** * Converts characters like ĖČĘĄ -> ecea, removes non letter and non number characters * @param str the string * @signature * P.normalizeString(str); * @example * P.normalizeString("Super#@! ===-0- ball %%% cup") // => super0ballcup * @data_first * @category String */ export function normalizeString(str) { return str .toLowerCase() .normalize('NFD') .replace(/[\u0300-\u036f]/g, '') .replace(/[^a-zA-Z0-9]/gm, ''); }