2011-04-05 115 views
2

請問該如何解釋/(?>[^<>]+)/? (PHP RegExp Engine)正則表達式解釋:(?> [^ <>] +)

謝謝。

+0

我不認爲這是一個有效的正則表達式。 – Czechnology 2011-04-05 22:54:37

+3

'?'IS在那裏有效。這是一個原子團體。 – Alex 2011-04-05 22:56:06

+0

+1有趣,從來沒有聽說過。我的正則表達式測試者拋出一個錯誤。 – Czechnology 2011-04-05 23:00:52

回答

4
(?>  # I had to look this up, but apparently this syntax prevents the regex 
      # parser from backtracking into whatever is matched in this group if 
      # the rest of the pattern fails 
    [^<>]+ # match ANY character except '<' or '>', 1 or more times. 
     ) # close non-backtrackable group. 

任何有興趣的一次性的模式,檢查出部分Once-only subpatternshttp://www.regextester.com/pregsyntax.html

+0

如果您使用的是Perl正則表達式,您應該始終查閱[相應的文檔。](http://perldoc.perl.org/perlre.html)。 – tchrist 2011-04-05 23:04:39

+1

@tchrist他在問關於PHP的問題,儘管 – climbage 2011-04-05 23:06:03

+1

你認爲* preg_ *函數的名稱在哪裏? – tchrist 2011-04-05 23:06:39