How to count number of spaces just after the date information? : <p>I have unstructured data that look like this:</p>

<pre><code>data &lt;- c("24-March-2017      product 1              color 1",
"March-2017-24              product 2                 color 2",
"2017-24-March  product 3              color 3")
</code></pre>

<p>I would like to count number of spaces between the date and the first character (product column) for each line. As shown in the sample data, the date format can vary. This information will be used to put the data into structured format.</p>

<p>What is the best way to perform this in R? I believe <code>gsub</code> can be used in this case, just not sure how to apply to count only number of spaces at the beginning of each line.</p>
