Find and replace a string in Python
<p>I have a string like this:</p>

<pre><code> line = "Student   =  Small   |1-2|   Student"
</code></pre>

<p>I want to replace this line to </p>

<pre><code> line = "StudentShort  =  Small  |1-2|    StudentShort"
</code></pre>

<p>The problem is I don't know wheither first and last words are <code>Student</code> or anything else in string. I mean it can be <code>Men</code>, <code>Women</code>, <code>Teacher</code> anything.</p>

<p>I only know that if there is <code>small</code> in string I have to replace first and last word with that name and short</p>

<p>Can some one help?</p>
