Function match

  • Given a regular expression and a string, returns true if the string matches the regular expression.

    Example

    const matchNumbers = match(/\d+/u);

    matchNumbers("123"); // true
    matchNumbers("abc"); // false

    Returns

    true if the string matches the regular expression, false otherwise.

    Parameters

    • regularExpression: RegExp | `/${string}/u` | `/${string}/su` | `/${string}/mu` | `/${string}/msu` | `/${string}/iu` | `/${string}/isu` | `/${string}/imu` | `/${string}/imsu` | `/${string}/gu` | `/${string}/gsu` | `/${string}/gmu` | `/${string}/gmsu` | `/${string}/giu` | `/${string}/gisu` | `/${string}/gimu` | `/${string}/gimsu`

      Instance of RegExp or a string.

    Returns ((text: string) => boolean)

      • (text: string): boolean
      • Parameters

        • text: string

        Returns boolean