title: Removing leading zeros from alphanumeric characters in R
body: <p>I have a character vector <code>d</code> with alphanumeric characters </p>
  
  <pre><code>d &lt;- c("012309 template", "separate 00340", "00045", "890 098", "3405 garage", "matter00908")
  
  d
  [1] "012309 template" "separate 00340"  "00045"           "890 098"         "3405 garage"     "matter00908"  
  </code></pre>
  
  <p>How can I remove the leading zeros from all the numbers in R?
   <code>as.numeric</code> will remove all leading zeros only in numeric or integer vectors. I have tried <code>gsub</code> with <code>regex</code> but could not get the desired results.</p>
  
  <p>The expected output is as follows</p>
  
  <pre><code>out &lt;- c("12309 template", "seperate 340", "45", "890 98", "3405 garage", "matter908")
  out
  [1] "12309 template" "seperate 340"   "45"             "890 98"         "3405 garage"    "matter908"  
  </code></pre>