how can you get the first unique substring in a given string.

for example i want to find the unique string being asked "**tr6hrvjh**" in

> 
> $string = "htr6hrvjhtr6hrvjhtr6hrvjhtr6hrvjh";
> 
> 
> 

i tried **substr\_count** and using **for()**, also tried nested loops. still can't get it work
do you have any method in order to retrieve the unique string? or is it possible to use regex?
i am currently using php. if you can do it in other programming languages please do so.

-- EDIT --

ok. just what **niftydude** said the unique string im referring to is repeated. sorry about that. let me rephrase the question

the first character in $string (h) is used as the 'limiter' for the unique string being searched. it indicates the end of the unique string being searched.

the second character (t) is the start of the unique string. that's why i said "tr6hrvjh"

what i have done is i looped per character in the $string starting from the first offset [1] which is (t). the loop will only end if

* You found the 'limiter' character which is 'h'
* The string already repeated itself for example while you are traversing on the $string you already have 'tr6hrvjh'. after another several loops you detected 'tr6hrvjhtr6' all over again. your loop must end.

the conditions for the 'unique' string are:

* must be alphanumeric only
* must be >= 5
* all characters in the $string must be in that 'unique' string. for example if the $string is **htr6ahrvjhtr6ahrvjhtr6ahrvjh** the unique string must be **tr6ahrvjh** not **tr6ah** which leaves **rvjh** in the $string

note that the $string always looks that way. the first and second character always acts as the last and the first character of the 'unique' string respectively. and the unique string is always repeated in $string, no other characters in between it's repetition.

another problem is that there are two h's in the string being searched. well i hope you understand it. feel free to comment :D

-- EDIT --

test strings i have encountered so far are like the ones i have given to you

> 
> htr6hrvjhtr6hrvjhÔi§¯ŸÍ©¥g§¬Ð™×ªhÖØ¡˜¦ÓkÕ¬šÕª—©«
> 
> 
> htr6hrvjhtr6Ôi§¯ŸÍ©¥g§¬Ð™×ªhÖØ¡˜¦ÓkÕ¬šÕª—©«
> 
> 
> 512354651235465Ôi§¯ŸÍ©¥g§¬Ð™×ªhÖØ¡˜¦ÓkÕ¬šÕª—©«
> 
> 
> 5123546512354651235Ôi§¯ŸÍ©¥g§¬Ð™×ªhÖØ¡˜¦ÓkÕ¬šÕª—©«
> 
> 
>