正则表达式

来源:互联网 发布:暗黑3淘宝上的悬赏箱子 编辑:程序博客网 时间:2024/06/04 18:59

 

Pattern pattern = Pattern.compile(/s*class);  //定义一个正则表达式

Matcher matcher 
= pattern.matcher("       class");  //要比较的内容

if (matcher.matchers())  //如果有匹配的内容的话
{
  System.out.println(
"The pattern matches the string");
}
else
{
  System.out.println(
"The pattern does not match the sting");
}

原创粉丝点击