title: regex from first character to the end of the string
body: <p>In a <a href="https://stackoverflow.com/questions/15895050/using-gsub-to-extract-character-string-before-white-space-in-r">related post</a> someone asked how to grab from beginning of string to first occurrence of a character.  I'd like to extend my own knowledge of regex by asking how to grab from a certain character of the string to the end.</p>
  
  <p><strong><em>How could I use regex (not <code>strsplit</code>) with gsub to grab from the beginning of the first space to the end of the string?</em></strong></p>
  
  <pre><code>dob &lt;- c("9/9/43 12:00 AM/PM", "9/17/88 12:00 AM/PM", "11/21/48 12:00 AM/PM")
  </code></pre>
  
  <p>Here I tried: <code>gsub(".*? ", "", dob)</code>  but it grabs from the last space not the first so I tried <code>gsub(".{1}? ", "", dob)</code> but it is overly greedy because of the period.</p>
  
  <p>Final solution would be the same as:</p>
  
  <pre><code>sapply(lapply(strsplit(dob, "\\s+"), "[", 2:3), paste, collapse=" ")
  ##[1] "12:00 AM/PM" "12:00 AM/PM" "12:00 AM/PM"
  </code></pre>
  
  <p><strong>NOTE: R regex is not identical to regex in general</strong></p>