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

Startseite
Nachricht löschen
Autor: ph10
Datum:  
To: pcunite
CC: pcre-dev
Betreff: 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