Python regex replacing \u2022
<p>This is my string:</p>

<pre><code>raw_list = u'Software Engineer with a huge passion for new and innovative products. Experienced gained from working in both big and fast-growing start-ups.  Specialties \u2022 Languages and Frameworks: JavaScript (Nodejs, React), Android, Ruby on Rails 4, iOS (Swift) \u2022 Databases: Mongodb, Postgresql, MySQL, Redis \u2022 Testing Frameworks: Mocha, Rspec xxxx Others: Sphinx, MemCached, Chef.'
</code></pre>

<p>I'm trying to replace the <code>\u2022</code> with just a space.</p>

<pre><code>x=re.sub(r'\u2022', ' ', raw_list)
</code></pre>

<p>But it's not working. What am I doing wrong?</p>

<p>You're using a raw string, with the <code>r</code>. That tells Python to interpret the string literally, instead of actually taking escaped characters (such as \n).</p>

<pre><code>&gt;&gt;&gt; r'\u2022'
'\\u2022'
</code></pre>

<p>You can see it's actually a double backslash. Instead you want to use >>> <code>u'\u2022'</code> and then it will work.</p>

<p>Note that since you're doing a simple replacement you can just use the <code>str.replace</code> method:</p>

<pre><code>x = raw_list.replace(u'\u2022', ' ')
</code></pre>

<p>You only need a regex replace for complicated pattern matching.</p>

python regex