special characters regex javascript code example
Example 1: regex special characters javascript
var regex = /^[a-zA-Z0-9!@
Example 2: how to check for special characters in javascript
var format = /[!@
if(format.test(string)){
return true;
} else {
return false;
}
Example 3: javascript escape regex
function escapeRegExp(input) {
const source = typeof input === 'string' || input instanceof String ? input : '';
return source.replace(/[-[/\]{}()*+?.,\\^$|
}
Example 4: regex for strings with specific letters javascript
let re = /ab+c/;
Example 5: regular expression javascript
if (/^https\:\/\/example\.com\/$/.exec(document.location)){
console.log("Look mam, I can regex!");
}