regular expression java

后端 未结 3 1151
失恋的感觉
失恋的感觉 2021-01-03 04:43

I am trying to Take the content between Input, my pattern is not doing the right thing please help.

below is the sudocode:

s=\"Input one Input Two In         


        
3条回答
  •  庸人自扰
    2021-01-03 05:18

    import java.util.regex.*;
    public class Regex {
    
        public static void main(String[] args) {
            String s="Input one Input Two Input Three"; 
            Pattern pat = Pattern.compile("(Input) (\\w+)"); 
            Matcher m = pat.matcher(s); 
    
             while( m.find() ) { 
             System.out.println( m.group(2) ); 
             }
        }
    }
    

提交回复
热议问题