Guest User

Untitled

a guest
Jul 16th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. f = IO.open("file.txt").split(/\n/)
  2. for i in (0..f.length)
  3. if f[i].to_s.match(/regexp_a/) then
  4. f[i] = f[i].gsub(/regexp_b/,/regexp_c/)
  5. end
  6. end
  7.  
  8. output = File.open("file.txt","w")
  9. f.each do |lines|
  10. output.write(lines + "\n")
  11. end
  12. output.close
Add Comment
Please, Sign In to add comment