sed - exchange words with delimiter
<p>I'm trying <strong>swap</strong> words around with <code>sed</code>, not <em>replace</em> because that's what I keep finding on Google search.</p>

<p>I don't know if it's the <code>regex</code> that I'm getting wrong. I did a search for <code>everything before a char</code> and <code>everything after a char</code>, so that's how I got the <code>regex</code>.</p>

<pre><code>echo xxx,aaa | sed -r 's/[^,]*/[^,]*$/'
</code></pre>

<p>or</p>

<pre><code>echo xxx/aaa | sed -r 's/[^\/]*/[^\/]*$/'
</code></pre>

<p>I am getting this output:</p>

<pre><code>[^,]*$,aaa
</code></pre>

<p>or this:</p>

<pre><code>[^,/]*$/aaa
</code></pre>

<p>What am I doing wrong?</p>