这个相当简单的朱莉娅问题使我有些困惑。
假设我有一个格式为“ xxx_xxx”的字符串数组。是否有一个将从“ _”开始删除所有内容的函数?
例
names = ["last1_first1","last2_first2"]
是否有一个简单的函数会返回
["last1","last2"]
这个相当简单的朱莉娅问题使我有些困惑。
假设我有一个格式为“ xxx_xxx”的字符串数组。是否有一个将从“ _”开始删除所有内容的函数?
例
names = ["last1_first1","last2_first2"]
是否有一个简单的函数会返回
["last1","last2"]
You are looking for
split
:Note that I am using the dot broadcasting syntax
split.()
here to apply thesplit
function elementwise to the array of names.我只是有一些语法问题