gpt4 book ai didi

javascript - 如何使用 javascript 和 )/分割文本

转载 作者:行者123 更新时间:2023-11-28 04:25:50 24 4
gpt4 key购买 nike

我是 JavaScript 新手。我面临使用 javascript 分割文本的问题。我必须分割的字符串如下

mobile)/index.m3u8

我的输出应该如下所示

mobile and index.m3u8

我尝试使用 .split("\\)"); 但它无法拆分。对此有任何帮助谢谢

最佳答案

如果你想使用 split 它将返回值作为数组。你可以试试这个

var str = 'mobile)/index.m3u8';
console.log(str.split(')/'));

或者,如果您想将 mobile)/index.m3u8 替换为 mobile 和 index.m3u8。只需使用

str.replace(')/',' and ');

关于javascript - 如何使用 javascript 和 )/分割文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45072952/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com