regex for special characters js code example
Example 1: regex special characters javascript
var regex = /^[a-zA-Z0-9!@#\$%\^\&*\)\(+=._-]+$/g
Example 2: js string to regex
const regex = new RegExp('https:\\/\\/\\w*\\.\\w*.*', 'g');
Example 3: regular expression javascript
// Tests website Regular Expression against document.location (current page url)
if (/^https\:\/\/example\.com\/$/.exec(document.location)){
console.log("Look mam, I can regex!");
}