Determine whether or not a RegExp matches an entire string (or the start of a string).

This function is valid in v2.0.0 to v2.24.2. This function has been downloaded 40 times.


{RegExp} rgx
The regular expression to be used.
{string=} opt_str Optional
If specified, rgx will be matched against the string to see if the regular expression matches from the beginning. If not specified, a function will be returned that will be used to match against rgx whenever it is called.
{boolean=} opt_onlyCheckStart Optional, Default:false
If true, rgx must only match the beginning of opt_str. If false, rgx must match the entire string opt_str.


If opt_str is given and is not null or undefined, a boolean will be returned. If opt_onlyCheckStart is true-ish the value returned will indicate if rgx simply matched from the beginning of opt_str. If opt_onlyCheckStart is false-ish, the value returned will indicate if rgx matched all of opt_str. If opt_str is not given or null or undefined a function to match against rgx will be returned which will accept a string as the 1st argument that will act as opt_str would have and a 2nd optional argument which will act as opt_onlyCheckStart would have and will return a boolean indicating if rgx matches str.

Required Function

This function directly requires the following function which is included automatically:

  • slice()
    Slice does not modify the original array, but instead returns a shallow copy of elements from the original array.

Requiring Functions

This function is directly required by the following functions:

  • isSpace()
    Test for space characters starting at the beginning of a string.
  • isWhitespace()
    Test for whitespace characters starting at the beginning of a string.