Skip to content

normalizeSpace

normalizeSpace(string) → string · String

Collapse all whitespace sequences (spaces, tabs, newlines) to single spaces. Trim leading/trailing.

  • string (required): the string to normalize
utlx
{
  spaces: normalizeSpace("  hello   world  "),       // "hello world"
  mixed: normalizeSpace("line1\n  line2\t\tline3"),  // "line1 line2 line3"
  empty: normalizeSpace("")                          // ""
}

Released under AGPL-3.0.