Function safeReplaceString

  • Replace a string in a text, optionally prepending, appending, replacing all occurrences, and/or calling a callback if the string is not found

    Parameters

    • source: string

      The source text

    • str: string

      The string to replace

    • newStr: string

      The replacement string

    • __namedParameters: {
          append?: boolean;
          notFoundCallback?: () => void;
          prepend?: boolean;
          replaceAll?: boolean;
      } = {}

    Returns string