[問題] (?(condition)yes-pattern|no-pattern) REGEX的問題
這是在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
Perl 近期熱門文章
PTT數位生活區 即時熱門文章