Reputation: 13
I am trying to replace every 6th comma in the line of text with a line break. I have tried replacing ,{6} with \n in textpad with no luck. Any ideas?
Upvotes: 0
Views: 391
Reputation: 39540
/^(([^\n,]+,){5}[^\n,]+),\s*/gm
with replacement \1\n
should work fine, dependent on your flavour.
/^((.*?,){5}.*?),\s*/gm
also works fine, but you can't have the DOTALL modifier.
Input:
this, is, my, string, and, it, is, very, nice, and, pretty, cool
this, is, my, string, and, it, is, very, nice, and, pretty, cool
this, is, my, string, and, it, is, very, nice, and, pretty, cool
this, is, my, string, and, it, is, very, nice, and, pretty, cool
this, is, my, string, and, it, is, very, nice, and, pretty, cool¨
Output:
this, is, my, string, and, it
is, very, nice, and, pretty, cool
this, is, my, string, and, it
is, very, nice, and, pretty, cool
this, is, my, string, and, it
is, very, nice, and, pretty, cool
this, is, my, string, and, it
is, very, nice, and, pretty, cool
this, is, my, string, and, it
is, very, nice, and, pretty, cool
Upvotes: 2