首页 > 解决方案 > 如何从 TypeScript 中的字符串中删除单引号

问题描述

我想从 TypeScript 中的字符串中删除单引号。我使用了以下方法来实现这一点。

var Id = this.currentId.replaceAll('"','');
var id = this.currentId.remove('\'', '');

尝试了上述方法。

提前致谢

标签: stringtypescript

解决方案


您可以使用String.prototype.replace查找和删除字符串中的所有单引号。

例子:

const stringWithoutSingleQuotes = stringWithSingleQuoutes.replace(/'/g, "")

推荐阅读