@yookue/ts-lang-utils
    Preparing search index...

    Function replaceFirst

    • 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 undefined | null | string

      the string that replaced the first occurrence in the given text

      David Hsing

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