简体   繁体   English

从字符串中删除非拉丁字符

[英]Removing non-Latin characters from a string

I'm trying to remove non-Latin characters from a string with Javascript. 我正在尝试使用Javascript从字符串中删除非拉丁字符。 I'm using the following code: 我正在使用以下代码:

text.replace(/[\u0250-\ue007f]/g, '')

I first thought it was working fine, until I discovered it also removes the 'f' character from the string. 我首先认为它工作正常,直到我发现它也从字符串中删除'f'字符。 Any suggestions? 有什么建议么?

尝试这个:-

 text.replace(/[\u0250-\ue007]/g, '');

Oops, I must be tired. 哎呀,我一定很累。 After posting and looking at it, I discovered the 'f' at the end of the expression... 在发布并查看之后,我在表达式的末尾发现了'f'...

So it should be 所以它应该是

text.replace(/[\u0250-\ue007]/g, '')

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

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