首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Eclipse开发 >

关于Pattern.matcher(name).matches();的有关问题

2012-01-05 
关于Pattern.matcher(name).matches()的问题。Pattern.matcher(name).matches()报这样的错误,can tmakeas

关于Pattern.matcher(name).matches();的问题。
Pattern.matcher(name).matches();报这样的错误,can 't   make   a   static   reference   to   the   non-static   method   matcher(charsequerence)   from   the   type   Pattern.请高手指点我一下。急,谢谢!

[解决办法]
正则的用法:
Pattern pattern = Pattern.compile(...);
Matcher m = pattern.matcher(...);
[解决办法]
import java.util.regex.*;

class Regex1{

public static void main(String args[]) {

String str= "For my money, the important thing "+

"about the meeting was bridge-building ";

String regEx= "a|f "; //表示a或f

Pattern p=Pattern.compile(regEx);

Matcher m=p.matcher(str);

boolean result=m.find();

System.out.println(result);

}

}

热点排行