startsWith 结合 字符串长度等就可以了啊。

解决方案 »

  1.   


    String matchStr = "'销售部'";
    String allStr = "'二级销售部','销售部','业务部','管理部','仓储部'";
    String[] list = allStr.split(",");
            for (String s: list) {
             if (s.equalsIgnoreCase(matchStr)) {
             System.out.println("存在!");
             break;
             }
            }
            
            String regex = "'销售部'";
            Pattern p = Pattern.compile(regex);
            Matcher m = p.matcher(allStr);
            if (m.find()) {
             System.out.println("存在!");
            }
      

  2.   

    str_workgroup.indexOf("'销售部'")这样
      

  3.   

    public static void main(String[] args) {
    String s = "'二级销售部','销售部','业务部','管理部','仓储部'";
    Matcher m = Pattern.compile("(?<=')销售部(?=')").matcher(s);
    while(m.find()){
    System.out.println("存在");
    return;
    }
    System.out.println("不存在");
    }
      

  4.   

    1:split之后,遍历数组去equals.
    2:存在Collection里面
      

  5.   


    +1024不用遍历 ,集合类有相应的方法就能判断,集合中是否有这个元素。
    contains()判断list ,vector 中是否包含该元素
      

  6.   

    上面的哥们的方法可以的,但是我感觉你既然有这种需求为什么不用list或是数组呢?为什么选择字符串拼接。