// Tests website Regular Expression against document.location (current page url)
if (/^https://example.com/$/.exec(document.location)){
console.log("Look mam, I can regex!");
}
let re = /ol/,
Characters , ., cX, d, D, f,
,
, s, S, , v, w, W, , xhh, uhhhh, uhhhhh, []
Assertions ^, $, x(?=y), x(?!y), (?<=y)x, (?<!y)x, , 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}
console.log(/'d+'/.test("'123'"));
// → true
console.log(/'d+'/.test("''"));
// → false
console.log(/'d*'/.test("'123'"));
// → true
console.log(/'d*'/.test("''"));
// → true
var regularExpression = /^(?=.*[0-9])(?=.*[!@#$%^&*])[a-zA-Z0-9!@#$%^&*]{6,16}$/;
^.*(?=.{8,})(?=.*[a-zA-Z])(?=.*d)(?=.*[!#$%&? "]).*$
---
^.* : Start
(?=.{8,}) : Length
(?=.*[a-zA-Z]) : Letters
(?=.*d) : Digits
(?=.*[!#$%&? "]) : Special characters
.*$ : End
//! Button Click Event
//! regular function
document.querySelector("button").addEventListener('click', handlClick);
function handlClick() {
alert("I got clicked!")//just to show it works
//what to do when click detected
}
//!anonymous function
document.querySelector("button").addEventListener('click',function handlClick() {
alert("I got clicked!")//just to show it works
//what to do when click detected
});
const regex1 = /^ab/;
const regex2 = new Regexp('/^ab/');