How to match everything up to the second occurrence of a character?

This will capture up to but not including the second comma:

[^,]*,[^,]*

English translation:

  • [^,]* = as many non-comma characters as possible

  • , = a comma

  • [^,]* = as many non-comma characters as possible

[...] is a character class. [abc] means “a or b or c”, and [^abc] means anything but a or b or c.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)