• Returns the string that replaced the first occurrence in the given text

    Parameters

    • Optionaltext: null | string

      the text to inspect

    • Optionalsearch: null | string | RegExp

      the string or regex to match

    • Optionalreplace: null | string

      the expected replacement string

    Returns string | undefined | null

    the string that replaced the first occurrence in the given text

    replaceFirst(undefined, undefined, undefined);    // undefined
    replaceFirst('foobar-foobar', 'foobar', undefined); // 'foobar-foobar'
    replaceFirst('foobar-foobar', 'foobar', 'hello'); // 'hello-foobar'