Sha256: 5f21b97614bce93308cdb68bd8ac1b715d8f6c07769bce499f933c8c7d1c4f67
Contents?: true
Size: 716 Bytes
Versions: 2
Compression:
Stored size: 716 Bytes
Contents
# encoding: utf-8 # frozen_string_literal: true module UnicodeTools module StringExt module Squish # Removes leading, trailing whitespace and # collapses remaining whitespace into one group each. # # string = " Hello\f\n\r\t\v\u00A0\u1680\u180e\u2000 # \u2001\u2002\u2003\u2004\u2005\u2006 # \u2007\u2008\u2009\u200a\u2028\u2029 # \u2028\u2029\u202f\u205f\u3000 World! " # string.squish => "Hello World!" def squish dup.squish! end def squish! gsub!(SURROUNDING_WHITESPACE_REGEX, '') gsub!(WHITESPACE_REGEX, ' ') self end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
unicode-tools-1.0.2 | lib/unicode-tools/string_ext/squish.rb |
unicode-tools-1.0.1 | lib/unicode-tools/string_ext/squish.rb |