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

Top Page
Delete this message
Author: ph10
Date:  
To: pcunite
CC: pcre-dev
Subject: 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