in reply to Getting Data from Between Two Commas

Splitting on commas is nice and obvious and all, but it seems likely to be simpler to split on $string, ignore the first returned section of text (since it was before the first occurrence of $string), and then use a regex to extract the text between the first and second commas in each of the remaining sections returned by split.

Regardless of whether you split on commas or on $string, there's a potential for trouble if $string appears between a pair of commas, but I think that splitting on $string is more likely to do the Right Thing. (Can't say for sure, though, as the correct behaviour in this case isn't clearly defined in the original question.)

  • Comment on Re: Getting Data from Between Two Commas