in reply to Re^2: Find number of short words in long word
in thread Find number of short words in long word
my $count =()= 'abrabrabrabra' =~ /b(?=rabra)/g;
Of course in this case you know that the first possible overlap starts at the second be, so even /bra(?=bra)/ works fine.
(I haven't benchmarked it, but I suppose that non-look-around literals are a bit faster, due to optimizations regarding the match length).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Find number of short words in long word
by AnomalousMonk (Archbishop) on Jul 14, 2009 at 23:37 UTC |