通过正则表达式匹配单个单词
/** 来 自 时 代 J a v a 公 众 号 - nowjava.com **/ import java.io.*; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void main(String args[])throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int no = Integer.parseInt(br.readLine()); while(no>0) { String str = br.readLine(); String pat="\\b(C|CPP|JAVA|PYTHON)\\b"; Pattern p = Pattern.compile(pat); Matcher m = p.matcher(str); if(m.find()) { /**来自 N o w J a v a . c o m**/ System.out.pr