没有环境,不好测试,,,大概思路:按照逗号切割, String s=s.replaceall("(/w+)/s+(/w+)","$1");应该就是这样吧

解决方案 »

  1.   

    正则:(?<=^|,)\s*([^,\s]+)import java.util.regex.*;public class TestTmp { 
        public static void main(String[] args) {
         String sa=" temp1,abc b1, temp2 d1,defh,ghxs gh";
            //(?<=^|,)\s*([^,\s]+)
            Pattern pattern = Pattern.compile("(?<=^|,)\\s*([^,\\s]+)");
            Matcher matcher = pattern.matcher(sa);
            int count = 0;
            while (matcher.find()) {
                System.out.println("第" + ++count + "项:【" + matcher.group(1) + "】");
            }
        }
    }