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()); } } }