title: regexp R - extract string between commas
body: <p>Because my csv file is broken, I'm reading it into R using:</p>
  
  <pre><code>dataDT &lt;- data.table::fread(".../test.csv", sep = NULL)
  </code></pre>
  
  <p>And it gives a dataset something like:</p>
  
  <pre><code>dataDT &lt;- data.table("ColA,ColB,ColC,ColD" = c("1,10,some text... , some text,,20190801",
                                                 "2,22,some text... , some text,,20190801",
                                                 "3,30,some text... , some text,,20170601"))
  dataDT
  &gt; dataDT
                         ColA,ColB,ColC,ColD
  1: 1,10,some text... , some text,,20190801
  2: 2,22,some text... , some text,,20190801
  3: 3,30,some text... , some text,,20170601
  </code></pre>
  
  <p>Now, what I want is to <strong>split the string in each row into 4 new columns</strong>:</p>
  
  <pre><code>targetDT &lt;- data.table(ColA = c(1,2,3), 
                         ColB = c(10,22,30), 
                         ColC = c("some text... , some text,", "some text... , some text,", "some text... , some text,"),
                         ColD = c("20190801","20190801",'20170601'))
  targetDT
  &gt; targetDT
     ColA ColB                      ColC     ColD
  1:    1   10 some text... , some text, 20190801
  2:    2   22 some text... , some text, 20190801
  3:    3   30 some text... , some text, 20170601
  </code></pre>
  
  <p>The logic would be:</p>
  
  <ul>
  <li>ColA has the string before 1st comma;</li>
  <li>ColB has everything between 1st and 2nd comma;</li>
  <li>ColD has the string after the last comma;</li>
  <li>ColC has the string in the middle part (it might contain additional commas).</li>
  </ul>
  
  <p>How to achieve the logic above?</p>
  
  <p>Edit_1:</p>
  
  <p>Sensitive data, sorry I can't provide the exact data. It looks like:</p>
  
  <pre><code>        ID,Code1,Project_Name,Report_Date
  1:     123123,1, A &amp; B,20100101
  2:     1413,2, C, D and E,20120101
  3: 53163,333, F, G,20140303
  4: 23453,44,This is a name,20160801
  5: 12645,555,5th test, to continue,20190501
  </code></pre>
  
  <p>So, everything before the 1st comma is definitely numbers, and so is everything between 1st and 2nd comma. Everything after last comma is definitely a date-like 8 digits number. The middle part can contain multiple commas but no quotes (Which I guess is the reason why fread treats comma as delimiters).</p>