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);
}
}