Rearrange a character string
<p>I have a character vector where some entries have a certain pattern at the end. I want to remove this pattern from the end and put it in front of the rest. </p>

<p>Example: </p>

<pre><code>#My initial character vector
names &lt;- c("sdadohf abc", "fsdgodhgf abc", "afhk xyz")
&gt; names
[1] "sdadohf abc"   "fsdgodhgf abc" "afhk xyz" 

#What I want is to move "abc" to the front
&gt; names
[1] "abc sdadohf"   "abc fsdgodhgf" "afhk xyz" 
</code></pre>

<p>Is there an easy way to achive this or do I have to write an own function? </p>