正则表达式验证是否含有所有单词
1个回答
展开全部
this.openReader();
String lineStr = new String();
int countOfWord = 0;
Pattern patternOfWord = Pattern.compile("这里要写上正则表达式");
Matcher m;
try {
while ( (lineStr = this.in.readLine()) != null ){
m = patternOfWord.matcher(lineStr);
if (m.matches())//如果匹配
countOfWord++;//则+1
}
this.closeReader();
return countOfWord;
}
String lineStr = new String();
int countOfWord = 0;
Pattern patternOfWord = Pattern.compile("这里要写上正则表达式");
Matcher m;
try {
while ( (lineStr = this.in.readLine()) != null ){
m = patternOfWord.matcher(lineStr);
if (m.matches())//如果匹配
countOfWord++;//则+1
}
this.closeReader();
return countOfWord;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询