Example 1: javascript regex
let reg = /abc/
reg = new RegExp('abc')
let str = 'Abc abc abc'
str.match(/abc/)
str.match(/abc/g)
str.match(/abc/i)
str.match(/abc/ig)
str.match('abc', 'ig')
Example 2: regular expression in javascript
let re = new RegExp('ab+c');
Example 3: using regex in javascript
var regex = /\s/g;
var regex = new RegExp("\s", "g");
Example 4: regular expression javascript
if (/^https\:\/\/example\.com\/$/.exec(document.location)){
console.log("Look mam, I can regex!");
}
Example 5: 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}