你可以使用字符串的split方法将字符串分割成两个子字符串。\n\njavascript\nconst str = '["image/36/8b41e5cb5e45d3dac69c9c458428078affedee.jpg","image/4a/62e716ab3d22d8596946d328ff888705293195.jpg"]';\nconst arr = str.split(',');\nconst firstString = arr[0].replace('[', '');\nconst secondString = arr[1].replace(']', '');\n\nconsole.log(firstString); // "image/36/8b41e5cb5e45d3dac69c9c458428078affedee.jpg"\nconsole.log(secondString); // "image/4a/62e716ab3d22d8596946d328ff888705293195.jpg"\n\n\n首先,使用split方法将字符串按逗号分割成一个字符串数组。然后,使用replace方法去除第一个字符串的左方括号和第二个字符串的右方括号。最后,将两个子字符串存储在变量中,即可得到结果。


原文地址: http://www.cveoy.top/t/topic/psIN 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录