I believe they are tapeworms. The best way to find out for sure, is to take your dog to the vet and bring a fresh stool sample with you!
Tape worm
Please, the only thing I know that is like that are maggots and I'm not sure they would be considered as worms, but I stopped eating rice because of that, and now I only eat brown rice the best to you