String StrCode1s = "\\x81"; 
String StrCode1e = "\\x9f";  
String StrCode2s = "\\xe0";  
String StrCode2e = "\\xef";  
String StrCode3s = "\\xa1";  
String StrCode3e = "\\xdf";  
String StrCode ="XXX";我怎么判断StrCode的值,是不是在StrCode1s与StrCode1e或者在StrCode2s与StrCode2e之间呢?
  谢谢大家了,很急的。谢谢

解决方案 »

  1.   

    是不是表示16进制的数? 直接用 String 类的 compareTo 方法就可以
      

  2.   

    我试了,用compareTo方法不行。不能达到预期的结果。所以必须用正则表达式。各位大哥,帮帮忙啊。谢谢了
      

  3.   

    String StrCode1s = "\\x81";
    String StrCode1e = "\\x9f";
    String StrCode2s = "\\xe0";
    String StrCode2e = "\\xef";
    String StrCode3s = "\\xa1";
    String StrCode3e = "\\xdf";
    int i1s = Integer.parseInt(StrCode1s.substring(3, 5), 16);
    int i1e = Integer.parseInt(StrCode1e.substring(3, 5), 16);
    int i2s = Integer.parseInt(StrCode2s.substring(3, 5), 16);
    int i2e = Integer.parseInt(StrCode2e.substring(3, 5), 16);
    int i3s = Integer.parseInt(StrCode3s.substring(3, 5), 16);
    int i3e = Integer.parseInt(StrCode3e.substring(3, 5), 16);

    String s = "\\xa6";
    int is = Integer.parseInt(s.substring(3, 5), 16);

    if(is>=i1s && is<=i1e)
    System.out.println("该字符串位于StrCode1s和StrCode1e之间");
    if(is>=i2s && is<=i2e)
    System.out.println("该字符串位于StrCode2s和StrCode2e之间");
    if(is>=i3s && is<=i3e)
    System.out.println("该字符串位于StrCode3s和StrCode3e之间");