Top > Ruby [2.2.2] > squeeze


String# squeeze

p "aabbccdd1223445".squeeze     # "abcd12345"
p "aacchhaa__ppoorruuttee__ppiiiippoo".squeeze     # "acha_porute_pipo"
p "ababab".squeeze     # "ababab"

見たままですが、横に並んだ文字は1文字にします。



Copyright © 2015 AchaPorutePiipo All Rights Reserved.