Skip to content

Instantly share code, notes, and snippets.

@ssig33
Created December 12, 2012 09:24
Show Gist options
  • Select an option

  • Save ssig33/4266350 to your computer and use it in GitHub Desktop.

Select an option

Save ssig33/4266350 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#coding:utf-8
class String
def remove_space_from_ruby
str = self.dup
self.scan(/<rt>.*?<\/rt>/).each{|x|
str.sub!(/#{x}/ , x.gsub(/ | /, ''))
}
str
end
end
ARGV.each{|x| open("#{x}.removed.txt", 'w'){|f| f.puts open(x).read.remove_space_from_ruby} }
$ ruby remove_space_from_ruby.rb hoge.txt

などとすると hoge.txt.removed.txt が生成される。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment