String s="=a.aaaa =abc =123 =b.bbbb";
//想输出 
abc 
123匹配表达式怎么写 ? 求教~~

解决方案 »

  1.   

    String s="=a.a23a =abc =123 =b.babb";恩 没有点
      

  2.   

    的字符串 返回 abc 123 这样
      

  3.   


    public static void main(String[] args) {
    String s="=a.a23a =abc =123 =b.babb";
    Matcher m = Pattern.compile("(?<=\\=)[^\\.]+?(?=[ $])").matcher(s);
    while(m.find()){
    System.out.println(m.group());
    }
    }
      

  4.   


    //修改一下:
    String s="=aaa =a.a23a =abc =123 =b.babb =ccc";
    Matcher m = Pattern.compile("(?<=\\=)[^\\.]+?(?=($|\\s))").matcher(s);
      

  5.   


    package com;import java.util.regex.*;public class RegexDemo {
    public static void main(String[] args) {
    String s="=a.aaaa =abc =123 =b.bbbb";
    Pattern p = Pattern.compile("=([\\w]{3})");
    Matcher m = p.matcher(s);
    while(m.find()){
    System.out.println(m.group(1));
    }
    }
    }
      

  6.   

    System.out.println(s.substring(s.lastIndexOf('a'),s.indexOf('c')+1)+"\n"+s.substring(s.indexOf('1'),s.indexOf('3')+1));
      

  7.   


    import java.util.regex.*;public class RegexDemo {
        public static void main(String[] args) {
            String s="=a.aaaa =abc =123 =b.bbbb";
            Pattern p = Pattern.compile("\\=[^\\.]+\\s");
            Matcher m = p.matcher(s);
            while(m.find()){
                System.out.println(m.group(1));
            }
        }
    }
      

  8.   


    String s="=a.aaaa =abc =123 =b.bbbb =d1d"; 这样的话 最后字段d1d取不出