// 'Apple' : valid
// 'Apple : Invalid
// Apple : Invalid
if(str.indexOf('\'') > -1 && str.indexOf('"') > -1){
// do something
}
这将检测字符串是否包含单引号和双引号。
如何检查字符串是否以单引号开头和结尾。 (正则表达式)?
最佳答案
if(str[0] == "'" && str[str.length - 1] == "'"){
// do something
}
关于javascript - 检查字符串是否用单引号括起来 Javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28076624/