[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Regular expressions, PCRE [was: Relation(s) between/among Kate, Kwrite, and Katepart]



On Mon, Apr 21, 2025 at 12:08:53AM +0000, David wrote:
> On Sun, 20 Apr 2025 at 17:42, <tomas@tuxteam.de> wrote:
> > On Sun, Apr 20, 2025 at 05:58:31PM +0100, debian-user@howorth.org.uk wrote:
> 
> > > Err, did you notice the bit in that reference that says: "It documents
> > > regular expressions in the form available within KatePart, which is not
> > > compatible with the regular expressions of perl"? Note that PCRE stands
> > > for Perl Compatible Regular Expressions.
> 
> > And note PCRE is not Perl's regexps, but just "inspired by". They
> > converged and diverged over their respective histories. To get an
> > idea of the current situation, perhaps [2] is relevant.
> 
> [...]
> 
> > [2] https://en.wikipedia.org/wiki/PCRE#Differences_from_Perl
> 
> Thanks for pointing that out. I was guilty of the same misconception
> when I erroneously wrote here yesterday:
> 
> > According to [?] it might be [?], which at a glance looks like it uses
> > PCRE (ie PERL, contradicting the above statement).
> 
> But there's no contradiction. My mistake was to assume that
> PCRE and PERL regex are the same codebase, but that's not correct.
> So it's not surprising that they might have some differences.
> Thanks for the useful wikipedia page.

I know, it's confusing. Perl was a step forward in REs because it
left the purity in favour of usability and convenience. It was a
step backward because it re-introduced backtracking (which was,
since Thompson, a solved problem), thus exhibiting exponential
run time in some cases.

If you like to disappear in rabbit holes, this [3] one is nice. If
not, still the pic at the beginning still shows impressively an
exponential runaway for Perl's re engine compared to Tcl's which
uses a Thompson algorithm. Note that this was back in 2007 and
quite possibly Perl's engine has been refined (it definitely has
been extended) since then.

Cheers

[3] https://swtch.com/~rsc/regexp/regexp1.html
-- 
tomás

Attachment: signature.asc
Description: PGP signature


Reply to: