我使用JavaScript创建了一个函数,它可以接受一个字符串作为参数,并根据正则表达式条件返回一个数组。|在某些地方,我想在管道迭代之前获取字符串。比如说--字符串:"Material: 100% Polyester | Three-button | Color: Gray"结果数组:["Material: 100% Polyester", "Three-button", "Color Gray"]如果需要更多信息,请告诉我
"Material: 100% Polyester | Three-button | Color: Gray"
["Material: 100% Polyester", "Three-button", "Color Gray"]
n53p2ov01#
使用split
split
const list = "Material: 100% Polyester | Three-button | Color: Gray" console.log(list.split(" | "))
1条答案
按热度按时间n53p2ov01#
使用
split