Matching a word after another word in R regex
<p>I have a dataframe in R with one column (called 'city') containing a text string. My goal is to extract only one word ie the city text from the text string. The city text always follows the word 'in', eg the text might be:</p>

<pre><code>'in London'
'in Manchester'
</code></pre>

<p>I tried to create a new column ('municipality'):</p>

<pre><code>df$municipality &lt;- gsub(".*in ?([A-Z+).*$","\\1",df$city)
</code></pre>

<p>This gives me the first letter following 'in', but I need the next word (ONLY the next word)</p>

<p>I then tried:</p>

<pre><code>gsub(".*in ?([A-Z]\w+))")
</code></pre>

<p>which worked on  a regex checker, but not in R. Can someone please help me. I know this is probably very simple but I can't crack it. Thanks in advance. </p>