import java.util.regex.Matcher;
import java.util.regex.Pattern;
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 *//**
 *
 * @author y
 */
public class Main {
    public static void main(String[] argc){
        String str="我你我你我我我我们你们们你你我我我们你你你你们我"; 
        Pattern p = Pattern.compile("[^我们]+");
        String[] t = p.split(str);
        for(int i=0;i<t.length;i++)
        {
            System.out.println(t[i]);
        }
    }
}这段可以参考下 [^我们]+ 表示多个除‘我’或’们‘的字符组成的串
上述代码通过该正则分割字符串

解决方案 »

  1.   

    我不知道用什么词来表达就用排除了- -简单的说就是实现
    [^词组]+  
    比如,匹配除"我们"这个词外的所有字符
    str="你我我们我你"
    输出:
    ---
    你我
    我你
    ---想一天了
      

  2.   

    public class Test {
    public static void main(String[] args) {
    String str = "我你我你我我我我们你们们你你我我我们你你你你们我";
    System.out.println(str.replaceAll("我们|你们", ""));
    }
    }