Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/auto-space.rb
Instance Method Summary collapse
Instance Method Details
#auto_space! ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/auto-space.rb', line 3 def auto_space! self.gsub! /((?![年月日号])\p{Han})([a-zA-Z0-9+$@#\[\(\/‘“])/u do "#$1 #$2" end self.gsub! /([a-zA-Z0-9+$’”\]\)@#!\/]|[\d[年月日]]{2,})((?![年月日号])\p{Han})/u do "#$1 #$2" end # Fix () [] near the English and number self.gsub! /([a-zA-Z0-9]+)([\[\(‘“])/u do "#$1 #$2" end self.gsub! /([\)\]’”])([a-zA-Z0-9]+)/u do "#$1 #$2" end self end |