@mudssky/jsutils
    Preparing search index...

    Function trim

    • 移除字符串两端指定的字符。

      Parameters

      • str: Nullable<string>

        需要修剪的原始字符串,可以为 null。

      • charsToTrim: string = ' '

        一个包含需要移除字符的字符串,默认为空格。这些字符将被视为一个集合,任何在开头或结尾处匹配此集合中字符的实例都将被移除。

      Returns string

      修剪后的字符串。如果输入字符串为 null 或 undefined,则返回空字符串。

      console.log(trim("  hello world  ")); // -> "hello world"
      console.log(trim("__hello__", "_")); // -> "hello"
      console.log(trim("-!-hello-!-", "-!")); // -> "hello"
      console.log(trim("/path/to/file/", "/")); // -> "path/to/file"
      console.log(trim(null)); // -> ""