我有一个这样的字符串:
14.015_KNECHT_178178
如何分割它:
art = 14.015
man = KNECHT
如您所见,分隔符为_
。
答案 0 :(得分:2)
string#split可以做到这一点。
>> (art,man,foo) = "14.015_KNECHT_178178".split '_'
=> ["14.015", "KNECHT", "178178"]
>> p art
"14.015"
=> "14.015"
>> p man
"KNECHT"
=> "KNECHT"
>> p foo
"178178"
=> "178178"
答案 1 :(得分:2)