Purification and regeneration of diluted caustic and acidic washing solutions by membrane filtration