Wiping your strings with a clean microfiber cloth after playing removes the sweat and oils that cause corrosion. Some players also use string cleaners made for guitar and bass strings.
Cleaning can extend string life, but it won't restore the tone of a heavily worn set. Replace strings when they no longer deliver the tone and feel you want.
