Re: [pcre-dev] Matching file contents as one string using P…

トップ ページ
このメッセージを削除
著者: ph10
日付:  
To: pcunite
CC: pcre-dev
題目: Re: [pcre-dev] Matching file contents as one string using PCRE_DOTALL
On Fri, 10 May 2013, pcunite@??? wrote:

> *.txt ---------------------------> (?=.*\.txt$)


And one more thing: the most efficient pattern for "ends with .txt" is

.*(?<=\.txt)

The .* rushes to the end of the pattern; then there is a lookbehind to
check the last 4 characters. That's it. Your pattern will skip to the
end, then backtrack *all the way to the start*, trying to match \.txt$
at each position. Not optimal. (Pattern matchers can be quite dumb.)

Philip

--
Philip Hazel