in reply to binary problem
Basically, capture all the zeros, then map the length function on each, and return that.my @counts = map { length } $string =~ /1(0*)/g;
Update: To get a count of characters after each 1, you could do something like
We want to use the greediness of .*, so we do. We use look-ahead so that we can count the 1's that follow, but not eat them.my @counts = map { length } $string =~ /1(?=(.*))/g;
------
We are the carpenters and bricklayers of the Information Age.
Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.
|
|---|