Yes, you can solve with a regex, but it is probably much better to have us help you fix the root cause -- to help us do that, can you post some code?
As for the regex, the concept is simply to replace double breaks with a single one, instead of removing all of them: s/\n\n/\n/sg
Or (depending on the desired behavior) you could do: s/\n\n+/\n/sg