From: "Iñaki Baz Castillo" Date: 2011-03-05T05:12:37+09:00 Subject: Re: printing regex results 2011/3/4 New C. : > My code is: > > str = "aaaDDDbDDDcDDDgHHyHjHJkkjUUh" > arr = str.scan(/([A-Z])\1{2}[a-z]\1{3}/) > print arr > > The match is DDDbDDD but the arr prints only the first letter D. > How do I get it to print the full string ("DDDbDDD")? I don't know why, but using [] rather than #scan does the work: str = "aaaDDDbDDDcDDDgHHyHjHJkkjUUh" arr = str[ /([A-Z])\1{2}([a-z])\1{3}/ ] print arr => "DDDbDDD" -- Iñaki Baz Castillo