Mark, that wonderfully colored worm is called a ribbon worm. It's not a dog parasite. Please see image...
There's no need for a vet visit!
He didn't eat it - it would have been digested. It hitched a ride home and found feces to climb into. I don't know any other worm but a ribbon worm that looks like this and by the priniple of Occam's Razor his having going to the beach should be the clincher.
Thank you for your kind accept. I appreciate it. You may receive an inappropriate follow-up from the site ostensibly sent by me. It wasn't and I apologize in advance should you receive it.