[問題] (?(condition)yes-pattern|no-pattern) REGEX的問題

看板Perl作者 (Art of Life)時間17年前 (2007/12/17 17:02), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
這是在perldoc中perlre中的一段... (?(condition)yes-pattern|no-pattern) (?(condition)yes-pattern) WARNING: This extended regular expression feature is considered highly experimental, and may be changed or deleted without notice. Conditional expression. (condition) should be either an integer in parentheses (which is valid if the corresponding pair of parentheses matched), or look-ahead/look-behind/evaluate zero-width assertion. For example: m{ ( \( )? [^()]+ (?(1) \) ) }xmatches a chunk of non-parentheses, possibly included in parentheses themselves. 小弟看了很久,卻還是不明白condition中的意義還有pattern的意義.... 在programing perl第162頁有提到一下... 此外讓人困惑的是另一個語法 (??{...})..在同一頁也有提到.. 但是卻沒有詳細說明... 將它的example貼到perl上也確實能運行... 不知道版上的高手們能不能指點小弟一下...到底這幾個regex的用途和寫法是如何? 小弟十分感激!! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.123.222.163
文章代碼(AID): #17PZivSI (Perl)
文章代碼(AID): #17PZivSI (Perl)