import java.util.regex.*;
import java.util.Scanner;class wrenwren
{
public static void main(String args[])   throws   Exception
{
Scanner cs = new Scanner(System.in);
System.out.println("输入:");
String a = cs.ReadLine();
Pattern p = Pattern.compile("w.5{2}");
Matcher m = p.matcher(p);
if(m.find()){
System.out.println(a);

}
}
}

解决方案 »

  1.   

    Scanner 有那样的方法吗,Matcher m = p.matcher(p);改成Matcher m = p.matcher(a);,应该是匹配字符串a吧。
      

  2.   

    next.Byte(),nextDouble(),nextFloat,nextInt(),nextLine(),nextLong(),nextShot()
      

  3.   

    首先建议楼主查看API,没有什么特别的,不试试看怎么能知道呢,
    首先Scanner对象就没有readLine方法,即使有方法,按照java的编写规范,是绝对不会出现类似ReadLine此类以大写字母开头的方法的,还有,猜楼主的意思是要分割输入的字符串,Scanner类就有带利用正则表达式分割字符串的方法。哦,顺便再说一句,楼主写的类名首字母也要大写啊。多个单词每个单词首字母大写
      

  4.   

    import java.util.*;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;public class wrenwren {
    public static void main(String args[])   throws   Exception
        {
            Scanner cs = new Scanner(System.in);
            System.out.println("输入:");
            String a="";
            while(cs.hasNextLine()){
             a=cs.nextLine();       
              Pattern p = Pattern.compile("w.5{2}");
                 Matcher m = p.matcher("w.5{2}");
                 if(m.find()){
                     System.out.println(a);
                 }
            }
      
        }
    }
      

  5.   

    import java.util.regex.*;
    import java.util.Scanner;class wrenwren
    {
        public static void main(String args[])   throws   Exception
        {
            Scanner cs = new Scanner(System.in);
            System.out.println("输入:");
            String a = cs.next();
            Pattern p = Pattern.compile("w.5{2}");
            Matcher m = p.matcher(a);
            if(m.find()){
                System.out.println(a);
            
            }
        }
    }