regex special characters javascript
var regex = /^[a-zA-Z0-9!@#\$%\^\&*\)\(+=._-]+$/gfunction escapeRegExp(input) {
const source = typeof input === 'string' || input instanceof String ? input : '';
return source.replace(/[-[/\]{}()*+?.,\\^$|#\s]/g, '\\$&');
}
var format = /[ `!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/;
// ^ ^
document.write(format.test("My@string-with(some%text)") + "<br/>");
document.write(format.test("My string with spaces") + "<br/>");
document.write(format.test("MyStringContainingNoSpecialChars"));// Tests website Regular Expression against document.location (current page url)
if (/^https\:\/\/example\.com\/$/.exec(document.location)){
console.log("Look mam, I can regex!");
}
Also in JavaScript:
- follow and unfollow node js button
- Supported by YAML but not supported by JSON:
- downcasting js
- react native create button
- how display same paragraph in all pages of website in js
- chart.js npm install
- jquery append before
- disabled radio button
- play sound with keydown javascript
- string interpolation
- javascript reverse array without modifying
- jest mock class
- create array text javascript
- displaying the date react
- flatlist footer react native
- react native app slow lagging image
- tableau javascript
- pause console debugger in react
- javascript change background color
- cypress json schema vs code
- react spring transition animations
- create overlay js
- create a html table dynamically using javascript
- nodejs zlib