In matlab: I want to find the length of longest i-segment in the sequence for i ∈{H,E }.
Example: HHHCCEEECCCHHHHCCCCC
lengh of longest H-segment in sequence is: 4
How should i do this?
One-liner with regexp
:
max(cellfun(@numel, regexp(str, '([HE])\1+', 'match')))