They're most likely not planaria worms. Odds are better that they're "detritus worms" or any species of Oligochaetes worms. These usually crop up as indicators of a system that has a large bio-load and/or low oxygen content.
Trapping these harmless worms will prove futile in eradicating them. All you need is to miss one worm and these hermaphroditic worms will quickly repopulate.
The only "cure" is proper maintenance, adjusted feeding, and adequate filtration. If possible, adding species that consume these polychaete worms will keep the population in check. Loaches relish these worms as do cory cats and other small burrowing feeders.
BTW, there are many articles on the net that have labeled these worms as planaria. These IDs are incorrect.