更新时间:2023-11-26 19:17:22
使用正则表达式要简单得多.
using Regex is much simpler.
var str = '.abc'
var result = !!str.match(/^[.,:!?]/)
console.log(result)
/
表示正则表达式的开始/结束
/
indicates start/end of Regular expression
^
的意思是开始于"
[]
表示字符集".它将匹配[
和]
[]
means 'character set'. it will match any characters between [
and ]
此外,该应用程序对于学习正则表达式非常有用! http://regexr.com/
Additionally, this app is quite good to learn Regex! http://regexr.com/
祝您有美好的一天! :D
Have a nice day! :D