Question

Im having trouble matching X number of commas in a csv file

sometext,moretext,moretext2,moretext3,moretext4

Im trying to match up to the 3rd comma, any help?

The best I have so far is:

/.\{3},
/.\{-},
/.\{0,3},

but none of those are doing it for me, what am I doing wrong?

Was it helpful?

Solution

This will match upto the third comma

/^\([^,]\+,\)\{3\} 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top