Create a new RegExp object.
Syntax
JSObject *
JS_NewRegExpObject(JSContext *cx, JS::HandleObject obj,
                   const char *bytes, size_t length,
                   unsigned flags);
JSObject *
JS_NewUCRegExpObject(JSContext *cx, JS::HandleObject obj,
                     const char16_t *chars, size_t length,
                     unsigned flags);
JSObject *
JS_NewRegExpObjectNoStatics(JSContext *cx, char *bytes, size_t length,
                            unsigned flags);
JSObject *
JS_NewUCRegExpObjectNoStatics(JSContext *cx, char16_t *chars, size_t length,
                              unsigned flags);
| Name | Type | Description | 
|---|---|---|
| cx | JSContext * | The context in which to create the new object. Requires request. In a  | 
| obj | JS::HandleObject | A pointer to a global object. | 
| bytesorchars | const char *orconst char16_t * | A pointer to the string that contains a regular expression. | 
| length | size_t | The length of bytesorchars, in characters. | 
| flags | unsigned | Regular expression flags. See below. | 
Flags
| Name | Description | RegExpconstructor flag | 
|---|---|---|
| JSREG_FOLD | Fold uppercase to lowercase. | i | 
| JSREG_GLOB | Global execution, creates array of matches. | g | 
| JSREG_MULTILINE | Treat ^and$as begin and end of line. | m | 
| JSREG_STICKY | Only match starting at lastIndex. | y | 
Description
JS_NewRegExpObject and JS_NewUCRegExpObject create a new RegExp instance. The flags from the built-in RegExp constructor properties ignoreCase, global, multiline, and sticky are OR'd in with the provided flags parameter.
JS_NewRegExpObjectNoStatics and JS_NewUCRegExpObjectNoStatics create a new RegExp instance. They do not OR in any RegExp constructor properties.