If I recall The Making of Star Trek correctly, it had machinery that broke down clothing into its constituent fibers, separated out the dirt and stuff, and reassembled the clothes as if brand new. Sort of a much lower-resolution equivalent of a replicator.