指定した文字を抜き出す
Top > Ruby [2.2.2] > slice
str = "AchaPorutePiipo" p str # "AchaPorutePiipo" str2 = str.dup rusult = str2.slice!(4,6) p str2 # "AchaPiipo" p rusult # "Porute" str3 = str.dup result2 = str3.slice!(4..6) p str3 # "AchautePiipo" p result2 # "Por" str4 = str.dup result3 = str4.slice!(/P.*P/) p str4 # "Achaeepo" p result3 # "PoruteP"