💾 Archived View for thrig.me › blog › 2023 › 10 › 31 › notnextchar.pl captured on 2024-07-09 at 01:56:01.

View Raw

More Information

⬅️ Previous capture (2023-11-14)

-=-=-=-=-=-=-

#!/usr/bin/perl
# notnextchar.pl - benchmark "capture before first b" regular expressions
use 5.36.0;
use Benchmark 'cmpthese';

my $s = ( 'a' x 9999 ) . 'but not these bytes';

cmpthese -5,
  { dotplus => sub { $s =~ /^(.+)b/   },
    dotplqu => sub { $s =~ /^(.+?)b/  },
    notnext => sub { $s =~ /^([^b]+)/ },
  }