title: Parsing street addresses by gsub in R
body: <p>I would like to parse street addresses with gsub, but I have hard time to understand regular expressions and how to use them correctly. The main problem is that street names consists one or more words, some addresses have apartment number and letter, some don´t. I would like parse all parts of the address to a different variable. </p>
  
  <p>Here is an example:</p>
  
  <pre><code>Data1 &lt;- data.frame(address = c("Wagon street 6", "Oscar de la Rosa Street 11 A", "Night street 35 B 2"))
  
  Data1
  
  &gt;Data1$sname &lt;- NA
  &gt;Data1$snumber &lt;- NA
  &gt;Data1$anumber &lt;- NA
  &gt;Data1$anumber &lt;- NA
  
  &gt;Data1$sname &lt;- gsub("(+.)\\s[^W]+$","\\1", Data1$address)
  &gt; Data1
  
                         address sname snumber anumber aletter
  &gt;1               Wagon street 6 Wagon      NA      NA      NA
  &gt;2 Oscar de la Rosa Street 11 A Oscar      NA      NA      NA
  &gt;3          Night street 35 B 2 Night      NA      NA      NA
  </code></pre>
  
  <p>All help and ideas are most welcome. </p>