Skip to content

Instantly share code, notes, and snippets.

@matsuda
Created September 21, 2010 10:59
Show Gist options
  • Save matsuda/589540 to your computer and use it in GitHub Desktop.
Save matsuda/589540 to your computer and use it in GitHub Desktop.
class String
def half_spaceize
self.gsub(/\s| /, ' ')
end
def half_spaceize!
self.gsub!(/\s| /, ' ')
end
# '-ー‐-' => '-'
def hyphenize
self.gsub(/\xE3\x83\xBC|\xE2\x80\x90|\x2D/, "\xEF\xBC\x8D")
end
def hyphenize!
self.gsub!(/\xE3\x83\xBC|\xE2\x80\x90|\x2D/, "\xEF\xBC\x8D")
end
# '~~∼〜˜' => '~'
def tildeize
self.gsub(/\xE3\x80\x9C|\xE2\x88\xBC|\xCB\x9C|\x7E/, "\xEF\xBD\x9E")
end
def tildeize!
self.gsub!(/\xE3\x80\x9C|\xE2\x88\xBC|\xCB\x9C|\x7E/, "\xEF\xBD\x9E")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment