Example 1: regular expression flags
Besides the regular expressions, flags can also be used to help developers with pattern matching.
regex = /sing/;
regex = /sing/i;
regex = /hello/g;
regex = /it is (sizzling )?hot outside/;
regex = /it is (?:sizzling )?hot outside/;
regex = /do (dogs) like pizza 1/;
regex = /do (dogs) like (pizza)? do 2 1 like you?/;
regex = /d(?=r)/;
regex = / (?<=r)d /;
Example 2: js string to regex
const regex = new RegExp('https:\\/\\/\\w*\\.\\w*.*', 'g');
Example 3: using regex in javascript
var regex = /\s/g;
var regex = new RegExp("\s", "g");
Example 4: what is regular expression in javascript
let re = /ol/,
Characters \, ., \cX, \d, \D, \f, \n, \r, \s, \S, \t, \v, \w, \W, \0, \xhh, \uhhhh, \uhhhhh, [\b]
Assertions ^, $, x(?=y), x(?!y), (?<=y)x, (?<!y)x, \b, \B
Groups (x), (?:x), (?<Name>x), x|y, [xyz], [^xyz], \Number
Quantifiers *, +, ?, x{n}, x{n,}, x{n,m}
Unicode \p{UnicodeProperty}, \P{UnicodeProperty} property escapes
let defaults = new RegExp('compiled');
defaults = { dotAll: false, flags: "", global: false, ignoreCase: false, falselastIndex: 0, multiline: false, source: "abc", sticky: false, unicode: false}