match 和 lastIndex 字符串检测差异

  • match 、replace 、search 这写不能识别特殊字符
  • indexOf 、indexof 能识别特殊字符
str.lastIndexOf('a') > -1 // 通过lastIndexOf 可以检测特殊字符,尤其*、.、+等

猜你喜欢

转载自www.cnblogs.com/liangcheng11/p/10227007.html