fork(1) download
  1. array1 = ["unit 1 : Unit 1","unit 2 : Unit 2","unit 3 : Unit 3","test : Test", "system1"]
  2. array2 = ["unit 1","unit 2","unit 3","test"]
  3. array1.each do |element|
  4. #see if element exists in array 2
  5. #if array2.include? element[/\A([^:]*?)\s*:/, 1]
  6. if array2.include? element.split(' : ').first
  7. #print the name of that element
  8. puts element
  9. end
  10. end
Success #stdin #stdout 0.02s 9656KB
stdin
Standard input is empty
stdout
unit 1 : Unit 1
unit 2 : Unit 2
unit 3 : Unit 3
test : Test