现在的位置: 首页 > 综合 > 正文

chomp方法

2013年10月08日 ⁄ 综合 ⁄ 共 257字 ⁄ 字号 评论关闭

chomp方法属于String类里面的:

"hello".chomp            #=> "hello"
"hello\n".chomp          #=> "hello"
"hello\r\n".chomp        #=> "hello"
"hello\n\r".chomp        #=> "hello\n"
"hello\r".chomp          #=> "hello"
"hello \n there".chomp   #=> "hello \n there"
"hello".chomp("llo")     #=> "he"

chomp方法是移除字符串尾部的分离符,例如\n,\r等,详细的见官网说明点击打开链接

抱歉!评论已关闭.