in reply to Recursive loops
Rather than stating your problem in theoretical generalities, it might be more helpful to give us a sample of your input data, desired output data, and specifically what you're checking for and replacing with. That way we can be sure the correct approach is given to you.