Mastering Regular Expression - 介紹 1 ( lookahead 光看不吃 )

Type                                                 Regex                  Successful if the enclosed subexpression . . .

============================================================================================

Positive Lookbehind                    (?<=......)                      successful if can match to the left
Negative Lookbehind                  (?<!......)                       successful if can not match to the left

Positive Lookahead                     (?=......)                        successful if can match to the right

Negative Lookahead                   (?!......)                          successful if can not match to the right

============================================================================================

##   lookahead , 光看不吃,只匹配,不消耗任何字符,對$1,$2...等特殊變量沒有影響。

##  以上列表按照順序分別是向左匹配,向左不匹配,向右匹配,向右不匹配。

##  個人感覺在不修改原來的字符串,只是定位,然後插入字符串的時候比較有用。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章