in reply to Find the boundaries of a substring in a string
TIMTOWTDI. Using your code as a starting point I would use pos to find the end point of the sequence. Here is a runnable example.
use strict; use warnings; my $seq = 'dddddddddBBBBBBBBBBBBDDDDDDDDBBBBBBBBBBBBBBddddddddddddddddddddBBBB +BBBBBBBBBBDDBBBBBBBBddddddddddddd'; while ($seq =~ /(B+)/g) { my $seg = $1; my $seg_length = length ($seg); my $seg_end = pos ($seq); my $seg_start = $seg_end - $seg_length; print $seg. "|" . $seg_start . "-" . $seg_end . "\n"; }
🦛
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Find the boundaries of a substring in a string
by Anonymous Monk on Jun 27, 2023 at 09:24 UTC | |
by hippo (Archbishop) on Jun 27, 2023 at 09:27 UTC | |
by Anonymous Monk on Jun 27, 2023 at 09:31 UTC | |
by hippo (Archbishop) on Jun 27, 2023 at 09:36 UTC | |
by Anonymous Monk on Jun 27, 2023 at 09:35 UTC |