如果字符串以/
开头直到下一个唯一字符,我想替换...我尝试过如下,但它只将所有事件替换成一个!我想替换所有出现的字符......
var textTitle = "///test///";
var result = textTitle.replace(/^\/{1,}/g, '../');
console.log(result); // wanted => ../../../test///
textTitle = "//test/";
result = textTitle.replace(/^\/{1,}/g, '../');
console.log(result); // wanted => ../../test/

答案 0 :(得分:1)
使用abp.multiTenancy.isEnabled
标志,对y
属性的每个成功方法采取一步:
lastIndex

答案 1 :(得分:0)
你可以尝试:
var textTitle = "///test///";
var result = textTitle.replace(/^\/{1,}/g, (match, key) => {
return match.split('').reduce((res, next) => res += '..' + next, '');
});
console.log(result);
var textTitle = "///test///";
var result = textTitle.replace(/^\/{1,}/g, (match, key) => {
return match.split('').reduce((res, next) => res += '..' + next, '');
});
console.log(result);