Regex to capture unknown number of repeated groups

前端 未结 1 507
半阙折子戏
半阙折子戏 2021-01-14 08:24

I\'m try to write a regular expression to use in a Java program that will recognize a pattern that may appear in the input an unknown number of times. My silly little exampl

相关标签:
1条回答
  • 2021-01-14 08:38

    (Similar question: Regular expression with variable number of groups?)

    This is not possible. Your best alternative is to use h.t, and use a

    while (matcher.find()) {
        ...
        ... matcher.group(1); ...
        ...
    }
    

    The feature does exist in .NET, but as mentioned above, there's no counterpart in Java.

    0 讨论(0)
提交回复
热议问题