UNPKG

@primer/primitives

Version:

Typography, spacing, and color primitives for Primer design system

14 lines (13 loc) 459 B
export const filterStringArray = (string) => { // match unsupported characters const regex = /[^a-zA-Z0-9]+/g; // replace any non-letter and non-number character and split into word array const stringArray = string .filter(Boolean) .join(' ') .replace(regex, ' ') .split(' ') // remove undefined if exists .filter((part) => Boolean(part) && typeof part === 'string'); return stringArray; };