regexsublimetext2

adding comma to each line using sublime text 2


I am trying to use sublime's text search and replace function and regex to match a string of number in each line and append a comma to each. So here's the sample file:

 273794103
 418892296
 134582886
 380758661
 109829186
 248050497
 2167935715
 374858669

I want this to be:

 273794103,
 418892296,
 134582886,
 380758661,
 109829186,
 248050497,
 2167935715,
 374858669,

I tried doing this (\d+)\n and replacing it with $1, but this doesn't work. Any idea why? FYI for those who are not into sublime but into regex, Sublime Text uses Python's regex engine.


Solution

  • I'd recommend this

    'Find What': $ // matching all ends of your lines
    'Replace With': , // replaces all line ends with a coma

    this will work with any file :-)