Expands regular expressions by expanding the character classes. Supports [:alnum:], [:alpha:], [:digit:], [:punct:], [:space:], or [:xdigit:] and allows for addition of other character classes.

This function is valid in v2.8.0 to v2.24.3. This function has been downloaded 59 times.


{RegExp|string} rgxOrCharClsName
Regular expression or name of the character class to add to future regular expressions passed to this function.
{string=} opt_charClass Optional
If rgxOrCharClsName is a string this should be defined and should be the definition of the character class without brackets. This character class will be added and will be used to expand future regular expressions passed into this function.


If rgxOrCharClsName is a regular expression this will be a modified version of it with the character classes expanded, otherwise this will be a boolean value indicating if the character class was successfully added.

Required Functions

This function directly requires the following functions which are included automatically:

  • has()
    Every object descended from Object inherits the hasOwnProperty method. This method can be used to determine whether an object has the specified property as a direct property of that object; unlike the in operator, this method does not check down the object's prototype chain.
  • typeOf()
    Either gets the type of a value or adds a constructor registering its custom type name.