如何从整个字符串中删除“-”?
我正在使用此行,但仅对第一个“-”有效,它不会删除其他“-”。
图片名称:cropped-Journal-trend-02.png
word1 AND word2 AND word4
答案 0 :(得分:1)
您可以添加全局的g
修饰符。第一次匹配后不会返回
imagePath: $(this).find('td:eq(3)').html().replace(/-/g, '')
答案 1 :(得分:1)
imagePath: $(this).find('td:eq(3)').html().replace(/-/g, '')
答案 2 :(得分:0)
var imagePath = "cropped-Journal-trend-02.png";
var newImagepath = imagePath.replace(new RegExp('-', 'g'),"");
可以请您尝试一下。它将删除所有-从您的字符串中