Removes given characters from both sides of the string. If you want to remove from one side of the string see trimStart and trimEnd.

trim("abcb", "ab"); // "cb"
trim("!aaa!", "!"); // "aaa"
trim("!aaa!!!", "!"); // "aaa"
trim("!aaa!!!", "!!!"); // "!aaa"
  • Parameters

    • source: string

      Source string.

    • characters: string

      Characters to remove, taken as a whole.

    Returns string