A straightforward way to do that is to inspect each character in sequence and compare it to the previous one. But that would be slow and annoying. It's easier to use a regex:
#!/usr/bin/perl -w use strict; $_ = "-----MMMMM------IIIII----MMM---OOOO---I---MMMM-----"; while (/(\w)(\1*)/g) { print "$1:".(1+pos()-length "$1$2")."-".pos."\n"; }
In reply to Re: group things?
by Joost
in thread group things?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |