JS_NewRegExpObject

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 JS_THREADSAFE build, the caller must be in a request on this JSContext.

obj JS::HandleObject A pointer to a global object.
bytes or chars const char * or const char16_t * A pointer to the string that contains a regular expression.
length size_t The length of bytes or chars, in characters.
flags unsigned Regular expression flags. See below.

Flags

Name Description RegExp constructor 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.

 

See Also

Document Tags and Contributors

 Contributors to this page: kscarfone, arai, fscholz, cdleary, Jorend
 Last updated by: kscarfone,