Regex fails to capture all groups

后端 未结 5 1221
北荒
北荒 2021-01-29 01:36

Using java.util.regex (jdk 1.6), the regular expression 201210(\\d{5,5})Test applied to the subject string 20121000002Test only captures <

5条回答
  •  粉色の甜心
    2021-01-29 02:14

    the regular expression "201210(\d{5,5})Test" applied to the subject string "20121000002Test" only captures group(0) and does not capture group(1)

    Well I can say I didn't read the manual either but if you do it says for Matcher.groupCount()

    Returns the number of capturing groups in this matcher's pattern. Group zero denotes the entire pattern by convention. It is not included in this count.

提交回复
热议问题