to check a well formed string or not