I think the question reflects a misunderstanding of Tolkien's writing process. Most people tend to think of The Lord of the Rings as three separate, distinct books in a series. However, this is not how they were created.
Tolkien had been working on the story for many years before it was finally published, and the only system by which they were separated from one another is by the six "books" into which Tolkien himself split them up. The publisher insisted on publishing the story in three volumes, which became the three books we know as The Fellowship of the Ring, The Two Towers, and The Return of the King. Tolkien was less than enthusiastic about this idea, and even the titles of each book were not the ones he initially suggested (his recommendation was The Shadow Returns, The Treason of Isengard, and The War of the Ring).
The important thing is that he didn't send each volume off to the publisher as it was completed. He wrote the entire story, then sent the whole thing off to the publisher, who then published the volumes one by one, with a gap of a year or so between each volume.
Before he ever sent the manuscripts to the publisher, however, he had been writing, editing, rewriting, revising, and altering the text constantly. As he finished each chapter, he would have new ideas that created continuity issues with the previous chapters. He would have to go back and rework those chapters. Then he'd write a new chapter, which created more continuity issues, and he'd go back and revise the previous chapters again, and so on.
The point is that he didn't just write one volume, send it to the publisher, and then start working on the next volume, only then coming to regret something he had written earlier. He had spent over a decade working on this project. Therefore, it doesn't make sense to suggest that he brought Gandalf back to life because he regretted killing him off. If he did regret killing Gandalf, he could have simply removed the reference to his death from the manuscript and rewritten it, like he rewrote everything else in the story (many times).
We have no reason to believe that, after he wrote about Gandalf's death, he wished he hadn't done so. From the time that he conceived of Gandalf's death, he probably already knew that Gandalf would be coming back, even more powerful than before. If he had had second thoughts about killing him, the problem could have been easily solved by revising the manuscripts and erasing any reference to the event. He had all the time he needed to do this, but he didn't. The only plausible explanation for his decision to leave in the death of Gandalf is that he truly wanted, even needed, it to happen.
To get a sense of just how much Tolkien rewrote, revised, and edited the stuff he had already written- and even the stuff he had already published- look as the posthumous works, like Unfinished Tales and The History of Middle-earth. The whole reason these books exist is because Tolkien continued to work on his previous projects for as long as he lived. Almost literally until the day he died, he was rethinking everything he had ever written, sometimes in quite profound ways.
We can see just how much Tolkien reworked his books by considering the fact that, in the first several versions of the first and second volumes, the character we know as Strider/Aragorn was actually a hobbit named Trotter. Tolkien stuck with this idea for quite some time before he ultimately decided to make the character a human named Strider/Aragorn. He made this decision after several chapters had already been written, and the change forced him to go back and rewrite a significant portion of the existing text. This wasn't an exceptional case, though, it was something that he was accustomed to doing as a matter of course. It's just the way he wrote.
He was willing to make such revisions even to account for minor details - in Wayne Hammond and Christina Scull's The Lord of the Rings: A Reader's Companion, the first chapter describes the great lengths Tolkien went to in order to ensure that the dates in his story made good chronological sense. He rewrote certain passages to provide enough time for Aragorn and his party to make it to Edoras at the appropriate point, for instance.
So as far as we know, Tolkien never regretted killing off Gandalf, because by the time he wrote that part of the story, he already knew that Gandalf would be coming back sooner than later.