title: R regex replace & vector
body: <p>How does one do <code>str_replace</code> with a "starting with" <code>^</code> and a vector?</p>
  
  <p>I am trying to remove the prefixes (Mr., Ms., Dr., Capt., etc.) from a list of names, only from the beginning. I have tried: <code>str_replace(name, prefix, '')</code>. This replaces only a few of the prefixes (Mr., Ms., Dr., Capt., etc.) from the vector of names but most prefixes are still present. At the same time I don't want to replace the Dr in say <code>Dr. Drake</code> to <code>ake</code>. <code>Dr. Drake</code> should be <code>Drake</code>.</p>
  
  <pre><code>name &lt;- c('Mrs. Emily S', 'Dr. Richard L', 'Dr. Drake D', 'Mr. Mrdrmsmrs', 'Test Name')
  prefix &lt;- c('Dr.', 'Mr.', 'Ms.', 'Mrs.', 'Capt.')
  # Wiktor Stribiżew's code
  str_replace(name, paste0("^(?:", paste(prefix, collapse="|"), ")(?!\\.)"), '')
  </code></pre>
  
  <p>There are whitespaces. However we can remove those with <code>trimws()</code> or <code>stringr::str_trim()</code></p>