import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Test
{
public static void main(String[] args)
{
String str ="中华人民共和国,简称(中国)。";
Matcher mat = Pattern.compile("(?<=\\()(\\S+)(?=\\))").matcher(str);//此处是中文输入的()
while(mat.find()){
System.out.println(mat.group());
}
}
}
|
