Skip to content

Instantly share code, notes, and snippets.

@atton
Created April 4, 2012 12:57
Show Gist options
  • Save atton/2300896 to your computer and use it in GitHub Desktop.
Save atton/2300896 to your computer and use it in GitHub Desktop.
double regexp "foobar" v2
# -*- coding: utf-8 -*-
# fooが頭に無いbarをファイルに出力する 2.2
array = ["foo","bar","baz","hoge"]
file_name = "./hoge.txt"
f = File.open file_name,"a+"
array.each do |head|
array.each do |middle|
array.each do |foot|
str = head + middle + foot
if !(str =~ /foobar/) && (str =~ /bar/)
f.puts str
end
end
end
end
f.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment