My dog had once barfed out something similar to that thing also. It's from something your dog ate. I suggest, take him out for a walk so he can eat some grass and induce vomiting, allowing him to barf out more of those things.
Any chance she has been getting into stuff? This looks like maybe something she threw up?