I would require to find a repeated pattern if it exists in a string or return a string in case repeated pattern does not exists.
Example:
String s = "abcabc"; Repeated pattern is abc
String s = "aba"; Repeated pattern is aba
String s = "abbbbbbba"; Repeated pattern is abbbbbbba;
String s ="abcdabcdabcd"; Repeated pattern is abcd;
If you refer to link we can solve this using regex Finding a repeated pattern in a string . But apart from regex is there some other way in which I can get it solved?