Regex to match continuous pattern of integer then space

后端 未结 4 947
一生所求
一生所求 2021-01-22 01:35

I\'m asking the user for input through the Scanner in Java, and now I want to parse out their selections using a regular expression. In essence, I show them an enu

4条回答
  •  春和景丽
    2021-01-22 02:27

    You want integers:

    \d+
    

    followed by any number of space, then another integer:

    \d+( \d+)*
    

    Note that if you want to use a regex in a Java string you need to escape every \ as \\.

提交回复
热议问题