Skip to content

Latest commit

 

History

History
14 lines (11 loc) · 404 Bytes

squeeze.md

File metadata and controls

14 lines (11 loc) · 404 Bytes

squeeze

Ruby strings' squeeze method can be used to remove repeating characters. It will remove as many consecutive repetitions as it finds, leaving just one behind. Or you can pass it a character to explicitly squeeze:

> "aabbbbbbbbcbc".squeeze
=> "abcbc"
> "  a   lot   of   extra  space".squeeze(' ')
# => " a lot of extra space"

source