in reply to group things?
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"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: group things?
by Anonymous Monk on Apr 25, 2008 at 22:30 UTC | |
by Joost (Canon) on Apr 25, 2008 at 22:34 UTC | |
by Anonymous Monk on Apr 25, 2008 at 22:39 UTC | |
by Joost (Canon) on Apr 25, 2008 at 22:41 UTC | |
by Anonymous Monk on Apr 25, 2008 at 22:53 UTC |