in reply to Re: Find the boundaries of a substring in a string
in thread Find the boundaries of a substring in a string

Can you help me understand how to use them in my example please?
  • Comment on Re^2: Find the boundaries of a substring in a string

Replies are listed 'Best First'.
Re^3: Find the boundaries of a substring in a string
by AnomalousMonk (Archbishop) on Jun 27, 2023 at 09:01 UTC

    Win8 Strawberry 5.8.9.5 (32) Tue 06/27/2023 4:54:38 C:\@Work\Perl\monks >perl use strict; use warnings; use Data::Dump qw(dd); my $seq = 'ddBddddBBBBBBBBBBBBDDDDDDDDBBBBBBBBBBBBBBddddddddddBBBBBBBB +BBBBBBDDBBBBBBBBddddddddd'; my $rx_sub_str = qr{ B+ }xms; my @endpoints; while ($seq =~ / $rx_sub_str /xmsg) { push @endpoints, [ $-[0], $+[0] ]; } dd \@endpoints; ^Z [[2, 3], [7, 19], [27, 41], [51, 65], [67, 75]]
    Use of index might be faster than a regex approach for large data.


    Give a man a fish:  <%-{-{-{-<