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

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:  <%-{-{-{-<