regular expression java

后端 未结 3 1138
失恋的感觉
失恋的感觉 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:12

    this does not work, because m.matches is true if and only if the whole string is matched by the expression. You could go two ways:

    1. Use s.split("Input") instead, it gives you an array of the substrings between occurences of "Input"
    2. Use Matcher.find() and Matcher.group(int). But be aware that your current expression will match everything after the first occurence of "Input", so you should change your expression.

    Greetings, Jost

提交回复
热议问题