我在构建一个正则表达式时遇到问题,该正则表达式将允许所有 UTF-8 字符,但 2 个字符除外:'_' 和 '?'
所以白名单是:^[\u0000-\uFFFF],黑名单是:^[^_%]
我需要将这些组合成一个表达式。
我尝试了以下代码,但没有按我希望的方式工作:
String input = "this";
Pattern p = Pattern
.compile("^[\u0000-\uFFFF]+$ | ^[^_%]");
Matcher m = p.matcher(input);
boolean result = m.matches();
System.out.println(result);
Run Code Online (Sandbox Code Playgroud)
输入:这个
实际输出:假
期望输出:真
我需要彻底打破while循环(空检查),然后转到外部for循环的下一个迭代。
我试过了
for(Product: product:ListofProducts){
while(null!=product.getDate){
if(product.getDate>specifiedDate){
doOnething()
}
else{
doAnotherThing()
}
continue;
}
Run Code Online (Sandbox Code Playgroud)
如果产品日期不为null,并且执行onething()或anotherthing(),那么我想转到for循环的下一个迭代