My first thought was not to use a regular expression, but to use something that separates the string into an array with a comma, but since you requested the regular expression.
most regular expressions allow you to specify a minimum or maximum match, so something like this is possible.
/(?:[^\,]*\,){6}([^,]*)/
This is intended to match any number of characters that are not a comma, followed by a comma six times exactly (?:[^,]*,){6}
- ?:
Says it cannot be written - and then for matching and writing any number of characters that are not a comma ([^,]+)
. You want to use the first capture group.
Let me know if you need more information.
EDIT: I edited above so as not to capture the first part of the line. This regular expression works in C # and Ruby.
source share