str = "abcadcdc"print [/(a[^c]*c)/, /(a.*c)/].flat_map{ |pattern| str.scan(pattern) }.reduce(:+)
Standard input is empty
["abc", "adc", "abcadcdc"]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!