how to check for special characters in javascript
var format = /[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]+/;
if(format.test(string)){
return true;
} else {
return false;
}
how to check for special characters in javascript
var format = /[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]+/;
if(format.test(string)){
return true;
} else {
return false;
}
occurences of special character in a string javascript
// program to check the occurrence of a character
function countString(str, letter) {
// creating regex
const re = new RegExp(letter, 'g');
// matching the pattern
const count = str.match(re).length;
return count;
}
// take input from the user
const string = prompt('Enter a string: ');
const letterToCheck = prompt('Enter a letter to check: ');
//passing parameters and calling the function
const result = countString(string, letterToCheck);
// displaying the result
console.log(result);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us