简体   繁体   English

如何替换javascript中javascript中的某些字母?

[英]How to I replace certain letters from javascript inside javascript?

I get out "Å, Ä, Ö" like this "à ¥, à ¤, à ¶" when printing data from an external JSON file. 当从外部JSON文件中打印数据时,我会像这样的“Ã,¥,Ã,¤,Ô一样得到“Å,Ä,Ö”。 This file has the wrong encoding, but I can not do anything about that file because it is from an API. 该文件的编码错误,但是由于该文件来自API,因此我无法对其进行任何处理。 But, is there a painless way of getting all "1" replaced with "A"? 但是,是否有一种轻松的方法将所有“ 1”替换为“ A”? I tried getting a UTF-8 encoded tag in my HTML document. 我尝试在HTML文档中获取UTF-8编码的标签。 Not helping. 没有帮助。

尝试使用正则表达式替换:

 wholetext.replace(/1/g,'A')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM