Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7832655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:20:09+00:00 2026-06-02T12:20:09+00:00

I have an alpha-numeric string and I want to check for pattern repetition in

  • 0

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

  1. 12341234qwe should tell me 1234 is repeated.
  2. 1234qwe1234 should NOT tell me that 1234 is repeated since its not continuous.
  3. 12121212 should be treated as 12 being repeated as that is the first set which would be found being repeated. But if there is an algorithm which would find 1212 as the repeated set before 12 then I guess it has to perform the steps again on 1212.

What I thought was I can store the integer part by iterating and comparing it with ( <= '0' && >= '9') in a different StringBuilder. Then I read about performing FFT on the string and it shows the repeated patterns. But I have no idea on how to perform FFT in Java and look for the results, also, I was hoping to try to do this without going to Signal Processing. I read about KMP pattern matching but that only works with a given input. Is there any other way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T12:20:16+00:00Added an answer on June 2, 2026 at 12:20 pm

    You can take help of regex to solve this I think. Consider code like this:

    String arr[] = {"12341234abc", "1234foo1234", "12121212", "111111111", "1a1212b123123c12341234d1234512345"};
    String regex = "(\\d+?)\\1";
    Pattern p = Pattern.compile(regex);
    for (String elem : arr) {
        boolean noMatchFound = true;
        Matcher matcher = p.matcher(elem);
        while (matcher.find()) {
            noMatchFound = false;
            System.out.println(elem + " got repeated: " + matcher.group(1));
        }
        if (noMatchFound) {
            System.out.println(elem + " has no repeation");
        }
    }
    

    OUTPUT:

    abc12341234abc got repeated: 1234
    1234foo1234 has no repeation
    12121212 got repeated: 12
    12121212 got repeated: 12
    111111111 got repeated: 1
    111111111 got repeated: 1
    111111111 got repeated: 1
    111111111 got repeated: 1
    1a1212b123123c12341234d1234512345 got repeated: 12
    1a1212b123123c12341234d1234512345 got repeated: 123
    1a1212b123123c12341234d1234512345 got repeated: 1234
    1a1212b123123c12341234d1234512345 got repeated: 12345
    

    Explanation:

    Regex being used is (\\d+?)\\1 where

    \\d        - means a numerical digit
    \\d+       - means 1 or more occurrences of a digit
    \\d+?      - means reluctant (non-greedy) match of 1 OR more digits
    ( and )    - to group the above regex into group # 1
    \\1        - means back reference to group # 1
    (\\d+?)\\1 - repeat the group # 1 immediately after group # 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a string containing alpha numeric characters. The script should return (echo) true
I want to create a pattern for the following format of string. I have
I have a regular expression ^[a-zA-Z+#-.0-9]{1,5}$ which validates that the word contains alpha-numeric characters
I have a string and I want to remove all non-alphanumeric symbols from and
Example input string: (F1 (F2 X (Y) Z) (F3 A B) What i want
I have a project in PHP and I want to make a password check
I have some strings containing alpha numeric values, say asdf1234 , qwerty//2345 etc.. I
For eg., i have alphanumeric string 'ABCDEF 0 0.450' and i need to get
I have an alphanumeric string like below, $string_1 = a4nas60dj71wiena15sdl1131kg12b and would like to
I have a XIB with a UIWebView with Alpha = 1.0, Background set to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.