in reply to Regexp help!!

Hi Kanish, Try to use Negative Look ahead (?!).

if ($a=~m#$text=~s(.)\s*(?<!\1)#) should be if ($a=~m#$text=~s(.)\s*(?!\1)#)

Regards,
Velusamy R.