Replace Comma with Line Break

Early this week, I had a simple technical problem that required me to replace all commas in a list with line breaks.  This should be a simple one that will take no more than 5 minutes.   I typed into Google “replace comma with line break” intent on a quick solution but no instant fix awaited.

Thus, I am writing about it in the hopes that whoever has to replace a comma with a line break will not have to scurry around looking for a solution.

If you want to know how to replace a comma with a line break, you clearly have a rather large comma delimited list with which you are dealing.  (If you just have a few words, you would do it manually, right?).  I had a list of keywords numbering more than 10,000 and so I could not do it manually.

But, for the sake of this article, let’s assume I simply had the following list of 10 golfers:   (This is the list of best finishers at this year’s British Open which,  if you did not see, you missed something special!)

Stewart Cink,Tom Watson,Chris Wood,Lee Westwood,Luke Donald,Retief Goosen,Mathew Goggin,Soren Hansen,Ernie Els,Justin Leonard

Ok, our goal is to turn this list of comma separated items into line separated items.

To manipulate text in many ways, I always use UltraEdit.  This is the best text editor and a requirement for anyone involved in SEO or text manipulation.  With UltraEdit, the solution is very simple.

With your document open, choose Search | Replace.  In the “Replace” Dialog Box, enter a comma in the “Find What” field.  In the “Replace With” field, put “^p ” without the quotes.  ^p will add a line break.

And…that’s it.  You are done.  Your list should now look like this:

Stewart Cink
Tom Watson
Chris Wood
Lee Westwood
Luke Donald
Retief Goosen
Mathew Goggin
Soren Hansen
Ernie Els
Justin Leonard

When you have thousands of entries to modify, I hope this little tip on how to replace a comma with a line break helps you.

Good luck!

Richard CummingsReplace Comma with Line Break

Comments 3

  1. Pingback: Show HTML Code On Web Page | Richard Cummings

  2. Nima

    Hi Richard, Thanks for this article, I’m trying to do the vice versa.. Any ideas how to do that? (Break line -> Comma).

    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *