[\u4e00-\u9fa5]+ 匹配一个或多个中文
[\u4e00-\u9fa5]  只匹配一个中文
它们并不匹配¥%^&*等字符啊,做个简单的测试就知道了。
import java.util.regex.*;
public class Test1 {
	public static void main(String[] args) {  
		Pattern p =Pattern.compile("[\u4e00-\u9fa5]+");
                               //下面就是你要匹配的字符,如果中文可以测试用p.matcher("中");
		Matcher m =p.matcher("%");
		System.out.println(m.matches());
		}
		} 

输出结果是false。

rejson = model.toString();
// 判断是否存在汉字,如果存在则进行转换
Pattern p = Pattern.compile("[\u4e00-\u9fa5]");
Matcher m = p.matcher(rejson);
if (m.find()) {
// 对所有/进行转义
rejson = rejson.replace("/", "\\/");

}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-04
  • 2021-10-14
  • 2021-10-31
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-08
  • 2022-12-23
  • 2021-06-24
  • 2022-12-23
相关资源
相似解决方案