Getting overlapping matches with multiple patterns in Java regex

前端 未结 3 447
甜味超标
甜味超标 2021-01-16 02:10

I have the same problem as in this link

but with multiple patterns. My regex is like:

Pattern word = Pattern.compile("([\\w]+ [\\d]+)|([\\d]+ suit         


        
3条回答
  •  忘掉有多难
    2021-01-16 02:54

    (?=(\b[\w]+ [\d]+))|(?=(\b[\d]+ suite))|(?=(\b[\w]+ road))
    

    Try this.See demo.Grab the captures.

    https://regex101.com/r/dU7oN5/16

    Use positive lookahead to avoid string being consumed.

提交回复
热议问题