Java:在缓冲的阅读器中提取至少10位的独特文本行

时间:2015-08-12 23:56:21

标签: java regex

我想使用正则表达式提取一个具有至少10位数字,短划线,字母,唯一字符等的唯一文本行,并且在打印后只有数字到控制台。 我有以下成功,但不能。

String texts =  "9 N l 00 I . \n ASSOCIATES TD '\nAB?! .1 A.\n 15 K V 2669-8 7030 ’ \n 5‘37?» 54 4’ 0630395026782582 § \n4654—8199-9146, < .*\nLE“; *1. 0501/2015 10:4 .1 AM g";

        BufferedReader rdr = new BufferedReader(new StringReader(texts));
          List<String> lines = new ArrayList<String>();
          for (String line = rdr.readLine(); line != null; line = rdr.readLine()) {
          System.out.println("The Buffered Reader lines are>>>>> "+lines.add(line));
          }
          for(String values : lines){

              String r="[^A-Za-z0-9]+"; 
             // String pp = "pmNo: 4:654—8199-9146, < .\\“ -";
              Matcher mm = Pattern.compile(r).matcher(values);
              System.out.println("2nd Special Found "+mm.find());
              boolean mb = mm.find();
              if(mb == true){
              System.out.println("The result>>>>> "+r); //I want to print 4654—8199-9146, < .*
                r = r.replaceAll("\\D+","");

                 System.out.println("The Buffered Reader lines are2>>>>> "+values); //I want to print 465481999146

            }



          }
          rdr.close();

我哪里不对?

0 个答案:

没有答案