string - 如何从 TypeScript 中的字符串中删除单引号
问题描述
我想从 TypeScript 中的字符串中删除单引号。我使用了以下方法来实现这一点。
var Id = this.currentId.replaceAll('"','');
var id = this.currentId.remove('\'', '');
尝试了上述方法。
提前致谢
解决方案
您可以使用String.prototype.replace查找和删除字符串中的所有单引号。
例子:
const stringWithoutSingleQuotes = stringWithSingleQuoutes.replace(/'/g, "")
推荐阅读
- amazon-web-services - AWS:创建新环境(tomcat-single-instance):带有 SSL 证书的 .ebextensions - 无法启动
- docusignapi - docusign NodeJS 中有没有一种方法可以使用 X-DocuSign-Authentication 进行身份验证
- laravel - Heroku 上部署的 API 的奇怪 ID 行为
- database - 将列表变量类型转换为 matplotlib 变量
- python - 值错误:错误长度 103 与索引 180 不匹配
- python - 如何将参数添加到在熊猫的 groupby 中调用的函数?
- javascript - 为什么我的可折叠链接在 Bootstrap 5 中不可点击?
- flutter - setState is not calling when Navigating to another page
- db2 - Installing a new DB2 subsystem at function level 100 (z/OS)
- .net-core - Using Audit.NET SqlDataProvider with Azure SQL and Managed Identity