Creating a RegExp Object

suggest change

Standard Creation

It is recommended to use this form only when creating regex from dynamic variables.

Use when the expression may change or the expression is user generated.

var re = new RegExp(".*");

With flags:

var re = new RegExp(".*", "gmi");

With a backslash: (this must be escaped because the regex is specified with a string)

var re = new RegExp("\\w*");

Static initialization

Use when you know the regular expression will not change, and you know what the expression is before runtime.

var re = /.*/;

With flags:

var re = /.*/gmi;

With a backslash: (this should not be escaped because the regex is specified in a literal)

var re = /\w*/;

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Regular Expression:
* Syntax
* Creating a RegExp Object

Table Of Contents
11 Arrays
12 Objects
14 Classes
16 Map
17 Set
24 Loops
27 Date
29 Scope
30 AJAX
32 Regular Expression
35 Cookies
41 JSON
44 Fetch
45 Modules
46 Screen
64 Console
68 Symbols
73 Modals
76 Events
86 Proxy
89 WeakMap
90 WeakSet
102 Tilde