Extract overlapping matches using split

前端 未结 3 1633
广开言路
广开言路 2021-01-06 16:22

How can I extract overlapping matches from an input using String.split()?

For example, if trying to find matches to \"aba\":



        
3条回答
  •  情书的邮戳
    2021-01-06 16:49

    I would use indexOf.

    for(int i = text.indexOf(find); i >= 0; i = text.indexOf(find, i + 1))
       System.out.println(find + " found at " + i);
    

提交回复
热议问题