Hello natol44,
Have you looked at the 3rd optional parameter of 'index'. 'index' is very fast and since you have a large string, you can loop until the end by starting the next search('index') with the end of the most recent end of your search. (untested code):
Note: There are working examples in the Perl Cookbook and also using Super Search.my $pos = 0; while ( $pos < length( $all ) ) { my $si = index ( $all, "<START>", $pos ); if ( $si < 0 ) { last; } my $sj = index ( $all, "<END>", $si+1 ); if ( $sj > $si+1 ) { ... Collect you string with 'substr' etc. } $pos = $sj + 4; # set search for finding next text. }
Regards...Ed
"Well done is better than well said." - Benjamin Franklin
In reply to Re: Search all occurences of text delimited by START and END in a string
by flexvault
in thread Search all occurences of text delimited by START and END in a string
by natol44
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |