Tests a value against a regular expression and returns a result if only one result is found.

  • If the expression does not match undefined is returned
  • If the expression uses global 'g' flag and more than one result is found an error is thrown
  • Parameters

    • reg: RegExp

      The regular expression to use

    • val: string

      The string to test with the regular expression

    Returns RegExResult