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

    From tomas@tuxteam.de@21:1/5 to David on Mon Apr 21 08:10:01 2025
    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

    -----BEGIN PGP SIGNATURE-----

    iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCaAXf9QAKCRAFyCz1etHa RjsuAJ0QTxBmk6/pv4oOHuuNduYqNE94ewCfYS/byKMqSEKF8NGJLeHi3AYy8eE=
    =Y8Vo
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Greg Wooledge@21:1/5 to tomas@tuxteam.de on Mon Apr 21 13:40:01 2025
    On Mon, Apr 21, 2025 at 08:04:44 +0200, tomas@tuxteam.de wrote:
    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

    It still has the issue.

    hobbit:~$ time perl -e '$s = "a" x 25; $r = "a?" x 25 . "a" x 25; if ($s =~ $r) { print "yes\n"; }'
    yes
    real 1.354 user 1.349 sys 0.004

    That's with perl 5.36.0 from Bookworm.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From tomas@tuxteam.de@21:1/5 to Greg Wooledge on Mon Apr 21 14:00:01 2025
    On Mon, Apr 21, 2025 at 07:34:13AM -0400, Greg Wooledge wrote:
    On Mon, Apr 21, 2025 at 08:04:44 +0200, tomas@tuxteam.de wrote:
    [...] quite possibly Perl's engine has been refined (it definitely has
    been extended) since then.

    [...]

    It still has the issue.

    hobbit:~$ time perl -e '$s = "a" x 25; $r = "a?" x 25 . "a" x 25; if ($s =~ $r) { print "yes\n"; }'
    yes
    real 1.354 user 1.349 sys 0.004

    That's with perl 5.36.0 from Bookworm.

    Thanks for checking :-)

    I have some emotional attachment to that runaway: it helped,
    long, long ago a friend of mine and me land an exciting new
    job and get to know a bunch of very good friends :-)

    Cheers
    --
    t

    -----BEGIN PGP SIGNATURE-----

    iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCaAYx9wAKCRAFyCz1etHa Ro3SAJkBq1DzWz/0gI6zVnUSf6dlrLAEGwCggMaYCUNR6N4gxGGp1MutJi8Oqsw=
    =O2ph
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nicolas George@21:1/5 to All on Mon Apr 21 16:30:01 2025
    Tom Browder (HE12025-04-21):
    $ time raku -e ‘my $s = “a” x 25; my $r = “a?” x 25 ~ “a” x 25; if
    ($s ~= $r) { say “yes” } ‘

    I almost asked if Raku uses pairs of Unicode quotes instead of the
    symmetrical ASCII one; then I noticed the single quotes, and I know the
    shell does not.

    Raku’s regular expression grammar is much better than Perl’s. Larry
    was very picky about that.

    This is a good occasion to ask:

    As a long-time Perl 5 programmer, I often wonder whether learning Raku
    would be worth it. Does it take a lot of time or is it close enough to
    be easy? What are the benefit? Will I find a trove of package already implementing network protocols and standard algorithms, or be able to
    run Perl 5 packages somehow? And so on.

    Do you know the answer to these questions? Or a place where somebody
    wrote them?

    Regards,

    --
    Nicolas George

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From tomas@tuxteam.de@21:1/5 to Nicolas George on Mon Apr 21 16:40:01 2025
    On Mon, Apr 21, 2025 at 04:19:43PM +0200, Nicolas George wrote:
    Tom Browder (HE12025-04-21):
    $ time raku -e ‘my $s = “a” x 25; my $r = “a?” x 25 ~ “a” x 25; if
    ($s ~= $r) { say “yes” } ‘

    I almost asked if Raku uses pairs of Unicode quotes instead of the symmetrical ASCII one; then I noticed the single quotes, and I know the
    shell does not.

    Raku’s regular expression grammar is much better than Perl’s. Larry
    was very picky about that.

    This is a good occasion to ask:

    As a long-time Perl 5 programmer [...]

    Do you know the answer to these questions? Or a place where somebody
    wrote them?

    Not the one you asked, but the Wikipedia [1] seems to have a pretty
    nice overview. I know it'd get /me/ started.

    Disclaimer: I've done lots of Perl 5, but no Perl 6 whatsoever yet
    (now if Someone (TM) threw a Perl 6 project over the fence which
    could allow me to pay my bills, I wouldn't mind ;-)

    Cheers

    [1] https://en.wikipedia.org/wiki/Raku_(programming_language)#Major_changes_from_Perl
    --
    t

    -----BEGIN PGP SIGNATURE-----

    iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCaAZWeAAKCRAFyCz1etHa Rs+FAJ9rHNh6pW40nSuzwg/2BlndLu01QgCeJ3soxSPd9WsCTcL2YspOJhBMIOU=
    =AFem
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Ritter@21:1/5 to Nicolas George on Mon Apr 21 17:50:01 2025
    Nicolas George wrote:
    Tom Browder (HE12025-04-21):
    $ time raku -e ‘my $s = “a” x 25; my $r = “a?” x 25 ~ “a” x 25; if
    ($s ~= $r) { say “yes” } ‘

    I almost asked if Raku uses pairs of Unicode quotes instead of the symmetrical ASCII one; then I noticed the single quotes, and I know the
    shell does not.

    Raku’s regular expression grammar is much better than Perl’s. Larry
    was very picky about that.

    This is a good occasion to ask:

    As a long-time Perl 5 programmer, I often wonder whether learning Raku
    would be worth it. Does it take a lot of time or is it close enough to
    be easy? What are the benefit? Will I find a trove of package already implementing network protocols and standard algorithms, or be able to
    run Perl 5 packages somehow? And so on.

    Do you know the answer to these questions? Or a place where somebody
    wrote them?


    The most important bit to know is that Raku is not Perl, it is
    an incompatible descendant of Perl, which is why:

    * Raku stopped being called Perl 6
    * the next major version of Perl will be Perl 7.

    -dsr-

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From debian-user@howorth.org.uk@21:1/5 to Nicolas George on Mon Apr 21 21:40:01 2025
    Nicolas George <george@nsup.org> wrote:
    Tom Browder (HE12025-04-21):
    $ time raku -e ‘my $s = “a” x 25; my $r = “a?” x 25 ~ “a” x 25;
    if ($s ~= $r) { say “yes” } ‘

    I almost asked if Raku uses pairs of Unicode quotes instead of the symmetrical ASCII one; then I noticed the single quotes, and I know
    the shell does not.

    Raku’s regular expression grammar is much better than Perl’s. Larry
    was very picky about that.

    This is a good occasion to ask:

    As a long-time Perl 5 programmer, I often wonder whether learning Raku
    would be worth it. Does it take a lot of time or is it close enough to
    be easy? What are the benefit? Will I find a trove of package already implementing network protocols and standard algorithms, or be able to
    run Perl 5 packages somehow? And so on.

    Do you know the answer to these questions? Or a place where somebody
    wrote them?

    Regards,

    Thanks for asking this question, Nicolas. And thanks to everybody that
    answered it. It's prompted me to take an initial look at Raku, for
    one. :)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)