09:06 上午 · 11月 06 ,2025 正則表達式踩坑 1、正則表達式 只要加了 /g 屬性,在執行 RegExp 的 api 時,都需要注意 reg.lastIndex 屬性值的變化 RegExp.exec(string) 一個指定字符串中執行一個搜索匹配 exec(string): array || null 參數 string 返回值 匹配成功 返回一個數組,此數組的第 0 個元素是與正則表達式相匹配的文本,第 1 個元素是 regexp , match , exec , testing