How to check for repeating sequence in an integer

后端 未结 5 1593
夕颜
夕颜 2021-01-31 18:15

I have an alpha-numeric string and I want to check for pattern repetition in it just for the integers. And they should be continuous.

Example

5条回答
  •  粉色の甜心
    2021-01-31 19:01

    Apache Commons Lang. has a class org.apache.commons.lang.StringUtils which has a method that counts the occurrences of the specific substring. It already exist, so you can use it directly instead of creating your own solution.

    //First parameter is the string to find and second param is the String to search.
    StringUtils.CountMatches("1234","12341234"); 
    

提交回复
热议问题