直接上代码.
package org.jimmy.autotranslate20181022.test; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Regular20181023 { public static void main(String[] args) { String reg = "(?!<[a-zA-Z0-9]+>)[u4e00-u9fa5][^<>]+(?!<</[a-zA-Z0-9]+>)"; Pattern pattern = Pattern.compile(reg); Matcher matcher = pattern.matcher("<a>空之律者</a> <b>神恩颂歌</b><c>影骑士·月轮</c>"); while(matcher.find()){ System.out.println(matcher.group() + " "); } } }
效果图: