in reply to search for nth occurrence of a pattern in a line

Sounds like an XY Problem to me. Why are you searching for the third occurrence of a comma in a string? Do you want to get at the fourth field in a comma-separated string? If so, use split().

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart
  • Comment on Re: search for nth occurrence of a pattern in a line