(?:pattern) 與 (?=pattern)都匹配pattern,但不會把pattern結果放到Matches的集合中。指針
(?:pattern) 匹配獲得的結果包含pattern。
(?=pattern) 則不包含。字符串
對字符串:"industry abc"的匹配結果:
industr(?:y|ies) ---> "industry"
industr(?=y|ies) ---> "industr"集合
(?:pattern) 消耗字符,下一字符匹配會從已匹配後的位置開始。
(?=pattern) 不消耗字符,下一字符匹配會從預查以前的位置開始,只預查,不移動匹配指針。移動
出處:https://www.jianshu.com/p/43af3e83e6e9
di