strip

Removes specific character types or substring(s) from a string. See also: keep()

function strip(str: string, options: StripOptions = {}): string

type CharacterType =
  | "letters"
  | "numbers"
  | "spaces"
  | "special"
  | "lowercase"
  | "uppercase"
  | "punctuation"

interface StripOptions {
  types?: CharacterType[]
  custom?: string[]
}

// Example:

strip("hello1234", { type: ["numbers"] }) //=> "hello"
strip("hello1234", { letters: true }) //=> "1234"
strip("hello, newman!", { punctuation: true }) //=> "hello newman"
strip("hello@#$%^", { specialChars: true }) //=> "hello"
strip("hello newman", { spaces: true }) //=> "hellonewman"
strip("hello newman", { terms: ["new", "man"] }) //=> "hello "