【发布时间】:2018-08-27 22:02:08
【问题描述】:
如果它是管道,我想从字符串中删除最后一个字符。我有
.replace(/\|(\s+)?$/, '')
我想添加一个参数delim 来替换,因为最后一个字符发生了变化。我正在尝试:
.replace(/\+delim +(\s+)?$/, '')
但没有运气。
使用该函数的代码:
rangeValues[cellRow][hn[j]] = rangeValues[cellRow][hn[j]].toString()
.split(frValues[i][0])
.join(frValues[i][1]).trim()
.replace(/\ + delim + (\s+)?$/, '');
【问题讨论】:
-
分隔符的“更改”未知?也许你可以在正则表达式的 () 内做一些条件。
标签: regex google-apps-script google-sheets