最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Removing non-Latin characters from a string - Stack Overflow

programmeradmin1浏览0评论

I'm trying to remove non-Latin characters from a string with 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. Any suggestions?

I'm trying to remove non-Latin characters from a string with 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. Any suggestions?

Share Improve this question edited Nov 28, 2012 at 18:02 dda 6,2032 gold badges27 silver badges35 bronze badges asked Nov 28, 2012 at 14:53 BjornBjorn 9041 gold badge10 silver badges29 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 16

Try this:-

 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...

So it should be

text.replace(/[\u0250-\ue007]/g, '')
发布评论

评论列表(0)

  1. 暂无评论