Hair worm infested

dic wood

I purchased some live rock online, It was loaded with hair worms.
Is there a way to get rid of them? There are some pics,

i had several large ones in my tank about 4 ft but i had a 6 foot tank. there good but if u want to get rid of it an arrow crab can but if u have a reef would reccomend because they eat a lot of reef animals including small fish 3in and down. i reccomend leaving it.