I currently use this regex to count the number of commas in a line of text:
^([^,]*,){9}[^,]*$
Here is a sample message from our test server:
2018-06-25T19:44:31.187Z,MAIL\Outbound Proxy Frontend MAIL,08D5D14527D3D0F3,1,192.168.20.1:717,192.168.20.23:28050,>,"220 MAIL.potato.ca Microsoft ESMTP MAIL Service ready at Mon, 25 Jun 2018 15:44:30 -0400",
Now this works but it also counts the comma within the quotes (near the end). I would need it to work with detecting the 8 commas, thus ignoring any inside quoted "" text. Can't get my head around it so any ideas how I could do this?
To provide context, this is to parse logs correctly from a mail servers and with my current setup if an email has one or multiple commas in the subject it breaks my regex detection...
NB. This isn't in a language but the regex engine behind is java based.
Not sure why flagged as duplicate. The linked question is for code based extraction and not count.