java 提取数据

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class TextNested {

    
    public static void main(String[] args) {
          
        String str="aaa<内层数据1>bbbbbb《内层数据2》ccc<伪装内层数据》ddd";
        Matcher m1=Pattern.compile("(?:(?<=[<])(?:.*?)(?=[>]))|(?:(?<=[《])(?:.*?)(?=[》]))").matcher(str);
        while(m1.find()) {
            System.out.println(m1.group());
        }
    }

}

 

posted @ 2015-11-23 18:41  fleam  阅读(433)  评论(0编辑  收藏  举报