search and replace a space with a tab at a specific location in a string
<p>I need some help replacing a space with a tab on a string with multiple spaces.
I need to search the string for a time format such as 08:20:10 and replace the space on the end with a tab.
My code is the following:</p>

<pre><code>alert = '9/14/2016 08:20:10 CH1 This is a test.'
str = re.sub (r'(/d{2}:\d{2}:\d{2})(\s)$', '\t', alert)
</code></pre>

<p>I've been unsuccessful in this endeavor. The output should look like:</p>

<pre><code>9/14/2016 08:20:10    CH1 This is a test.
</code></pre>

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

<p>How about a <em>positive lookbehind</em> without a line terminator:</p>

<pre><code>&gt;&gt;&gt; import re
&gt;&gt;&gt;
&gt;&gt;&gt; re.sub(r'(?&lt;=\d{2}:\d{2}:\d{2})\s', '\t', alert)
'9/14/2016 08:20:10\tCH1 This is a test.'
&gt;&gt;&gt;
&gt;&gt;&gt; print(_)
9/14/2016 08:20:10      CH1 This is a test.
</code></pre>

<p>Also, your <code>/d</code> should have read <code>\d</code></p>

python