UNPKG

codetrix

Version:

A lightweight lodash-style utility library

13 lines (12 loc) 300 B
/** * Removes all non-alphabetical characters from a string. * * @param str - The string to clean. * @returns A string with only alphabetic characters. * * @example * removeNonAlpha('Hello123!'); // 'Hello' */ export function removeNonAlpha(str) { return str.replace(/[^a-zA-Z]/g, ''); }