Lets say I have a sequence of numbers
1 2 3 4 1 2 3 4
As you can see there is a cycle here:
1 2 3 4
Now I am trying to make a regex expression to match a pattern. The pattern can be half the length of the sequence or 2 numbers long. This is what I have so far
Pattern cycle = Pattern.compile("((\\d+\\s)+(\\d+\\s))\\1");
I am given a string of numbers delimited by spaces. I am trying to use capture groups but not understanding it. Any help?
1 2 3 4 1 2 3