@mudssky/jsutils
    Preparing search index...

    Function removePrefix

    • 移除字符串中指定的前缀

      Parameters

      • str: Nullable<string>

        原始字符串

      • prefix: string

        需要移除的前缀

      Returns string

      移除前缀后的字符串,如果原始字符串不以该前缀开头则返回原字符串

      console.log(removePrefix("hello world", "hello ")); // -> "world"
      console.log(removePrefix("__hello__", "__")); // -> "hello__"
      console.log(removePrefix("test", "no")); // -> "test"
      console.log(removePrefix(null, "prefix")); // -> ""