替换文件名中的字符 ionic5 Angular IOS

发布于 2025-01-12 18:43:14 字数 149 浏览 0 评论 0原文

我在 ionic5 Angular IOS 中使用此代码将 é 替换为 %CC%81 但它不起作用

 const regex = /é/gi;
 fileName = fileName.replace(regex,"%CC%81");

I use this code in ionic5 angular IOS to replace é with %CC%81 but it's not work

 const regex = /é/gi;
 fileName = fileName.replace(regex,"%CC%81");

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一生独一 2025-01-19 18:43:14

您需要创建一个新的 RegExp ,如下所示:

const regex = new RegExp(/é/gi);

编辑:经过仔细检查,我注意到您的字母尝试替换的内容与您的 la péériodeé 字符串中的相同,即使它们对您来说看起来相同。因此,您需要在正则表达式中添加两种类型的“e”,例如:

const regex = new RegExp(/é|é/gi);

如果这没有按您预期的方式编译,则它可能是由于字母失去了其特征,所以为了安全起见 - 您可以复制第一个“e”(la péériodeé)并将其粘贴到正则表达式中的第一个位置,然后复制并粘贴第二个“e” (la péériodeé)。

You need to create a new RegExp as in:

const regex = new RegExp(/é/gi);

EDIT: After closer examination, I noticed that the letters you're trying to replace are not the same in your la péériodeé string, even if they look the same to you. So you'll need to add both types of 'e' in your regex, like:

const regex = new RegExp(/é|é/gi);

If this does not compile as you expect, it might be due to letters losing their characteristics, so to be safe - you can just copy your first 'e' (la périodeé) and paste it at the first position in regex, then copy and paste the second 'e' (la péériodeé).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文