title: How to take only that part of a string which occurs before a pattern of 2 dots?
body: <p>I used a code of regular expressions which only took stuff before the 2nd occurrence of a dot. The following is the code:-</p>
  
  <pre><code>colnames(final1)[i] &lt;- gsub("^([^.]*.[^.]*)..*$", "\\1", colnames(final)[i])
  </code></pre>
  
  <p>But now i realized i wanted to take the stuff before the first occurrence of a pattern of 2 dots.</p>
  
  <p>I tried </p>
  
  <pre><code> gsub(",.*$", "", colnames(final)[i]) (changed the , to ..)
   gsub("...*$", "", colnames(final)[i])
  </code></pre>
  
  <p>But it didn't work</p>
  
  <p>The example to try on
  KC1.Comdty...PX_LAST...USD......Comdty........</p>
  
  <p>converted to</p>
  
  <p>KC1.Comdty.</p>
  
  <p>or</p>
  
  <p>"LIT.US.Equity...PX_LAST...USD......Comdty........"</p>
  
  <p>to</p>
  
  <p>"LIT.US.Equity."</p>
  
  <p>Can anyone suggest anything?
  Thanks</p>