zoukankan      html  css  js  c++  java
  • 正则表达式相关

    1

    代码:

    public static void main(String[] args) {
            Scanner sc=new Scanner(System.in);
            System.out.println("请输入点评的条数");
            int line=sc.nextInt();
            sc.nextLine();
            String a[] = new String[line];
            for(int i=0;i<line;i++){
                a[i]=sc.nextLine();
            }
            String s[]={"网店地址","销售电话","代购"};
            regMatch(s,a);
        }
        
        public static void regMatch(String[] reg,String s[]){
            StringBuffer sb=new StringBuffer();
            for(int i=0;i<reg.length;i++){
                for(int j=0;j<reg[i].length();j++){
                    sb.append("\s*"+reg[i].charAt(j));
                }
                if(i==reg.length-1){
                    break;
                }
                sb.append("|");
            }
            Pattern p=Pattern.compile(sb.toString());
            Matcher m=null;
            for(String str:s){
                 m=p.matcher(str);
                while(m.find()){
                    System.out.print(m.group()+"	");
                }
                System.out.println();
            }
            
        }
        
  • 相关阅读:
    软件工程评分表
    评论
    团队成员介绍
    第九天冲刺
    第八天冲刺
    第七天冲刺
    第六天冲刺
    第五天冲刺
    第四天冲刺
    第三天冲刺
  • 原文地址:https://www.cnblogs.com/yaobolove/p/6289846.html
Copyright © 2011-2022 走看看