I have such a string "++++001------zx.......?????????xxxxxxx" I would like to extract the more than one length continuous sequences into a flattened array with a Ruby regex:
["++++",
"00",
"------",
".......",
"?????????",
"xxxxxxx"]
I can achieve this with a nested loop:
s="++++001------zx.......?????????xxxxxxx"
t=s.split(//)
i=0
f=[]
while i<=t.length-1 do
j=i
part=""
while t[i]==t[j] do
part=part+t[j]
j=j+1
end
i=j
if part.length>=2 then f.push(part) end
end
But I am unable to find an appropriate regex to feed into the scan method. I tried this: s.scan(/(.)\1++/x)
but it only captures the first character of the repeating sequences.
Is it possible at all?