0

I'd like to write a regular expression that checks that a line is:

  • Delimited (by a comma, for example)
  • Has at least n # of delimited items (say 10, for example)

The items in the delimited list need not be alphanumeric. Some will have special characters. Also, some items may be absent, so there is no assurance that there will be something between delimiters.

I'm a newb to regexp so if your answer involves anything extra clever/advanced please explain

Thanks much

Gumbo
  • 643,351
  • 109
  • 780
  • 844
Ben G
  • 26,091
  • 34
  • 103
  • 170

1 Answers1

2
/^[^,]*(?:,[^,]*){9,}$/
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
  • Thanks for the tips in the comments. Counting as an answer since this would benefit most people – Ben G Nov 25 '10 at 21:20