Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在javascript中有这个字符串:
var st="ab,cd,ef,gh";
如何将此字符串作为长度等于 4 的数组示例:
st should be like this : [ab cd ef gh]
利用split(..)
split(..)
st.split(",")
输出:
["ab", "cd", "ef", "gh"]
这将为您提供一个包含四个字符串元素的数组
var st="ab,cd,ef,gh"; string[] stArray = st.Split(',');
所以例如
stArray[1]
将返回“cd”