I need help with a regular expression (regex) in JavaScript that checks for special characters other than hyphen and forward slash.
function containsSpecialCharacters(str){
var regex = /[~`!#$%\^&*+=\-\[\]\';,/{}|\\":<>\?]/g;
return regex.test(str);
}
var result1 = containsSpecialCharacters("apple"); // false
var result2 = containsSpecialCharacters("apple-orange"); // false
var result3 = containsSpecialCharacters("apple#"); // true
var result4 = containsSpecialCharacters("/apple/orange"); // false