Tweakr
    Preparing search index...

    Function removePrefix

    • Removes the specified prefix from a string if it exists.

      Parameters

      • str: string

        The string to process.

      • prefix: string

        The prefix to remove.

      • Optionaloptions: { caseInsensitive?: boolean }

      Returns string

      The string without the prefix if it was present; otherwise, returns the original string.

      1.1.0

      removePrefix("unhappy", "un"); // "happy"
      removePrefix("hello", "he"); // "llo"
      removePrefix("world", "un"); // "world" (prefix not found)