Function rexecFirstMatch

  • Returns the first match of a regular expression in a string.

    Parameters

    • regex: RegExp

      The regular expression to be used for matching.

    • string: string

      The string in which to search for a match.

    Returns RexecYield | undefined

    The first match as an RexecYield object, or undefined if no match is found.

    Remarks

    This function is a part of RegExp utilities.

    Example

    rexecFirstMatch(/hello/g, 'hello world');;
    //=> { match: 'hello', index: 0, input: 'hello world', groups: undefined }

Generated using TypeDoc