Java正则表达式匹配基本多语言平面之外的字符 [英] Java regex match characters outside Basic Multilingual Plane
本文介绍了Java正则表达式匹配基本多语言平面之外的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在java中的unicode Basic Multilingual Plane外部匹配字符(意图删除它们)?
How can I match characters (with the intention of removing them) from outside the unicode Basic Multilingual Plane in java?
推荐答案
要删除所有非BMP字符,以下内容应该有效:
To remove all non-BMP characters, the following should work:
String sanitizedString = inputString.replaceAll("[^\u0000-\uFFFF]", "");
这篇关于Java正则表达式匹配基本多语言平面之外的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文