简体   繁体   English

Java检查字符串特殊字符

[英]Java Check String Special Character

I have a string that contains: ½ 我有一个字符串,其中包含:½

From my understand i belive this is \� 据我了解,我相信这是\�

Can someone help me with why this syntax does not work: 有人可以帮我解决为什么此语法不起作用的问题:

if (promotions.getText().contains("\uFFFD")) {
                return promotions;
}

½ is \½ ½是\\ u00BD

Therefore this should work 因此,这应该工作

if (promotions.getText().contains("\u00BD")) {

Try this: 尝试这个:

if (promotions.getText().contains("\u00BD"))
{ 
    return promotions;
}

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

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