title: How to account for special characters when splitting string in python
body: <p>I have several strings of the form &quot;[one or more words] [number] [one or more words]&quot; and I want to split them into the two strings and the number. For example, if the string is:</p>
  <pre><code>&quot;A sample string 20 something&quot;
  </code></pre>
  <p>I want to obtain:</p>
  <pre><code>str1 = &quot;A sample string&quot;
  numb = 20
  str2 = 'something'
  </code></pre>
  <p>I have (almost) achieved my goal with the following code:</p>
  <pre><code>for s in row.split():
      if s.isdigit():
          quants = s
  temp = row.split(&quot;{}&quot;.format(quants))
  str1 = temp[0].strip()
  str2 = temp[1].strip()
  </code></pre>
  <p>this works fine for most cases. However, there are 2 exceptions which I'm not able to handle:</p>
  <ol>
  <li><p>If the number is inside brackets, I want it to be counted as a string. For example:</p>
  <p>&quot;Some text (just as 1 example) 2 more words&quot;</p>
  <p>I want to have str1 = &quot;Some text (just as 1 example)&quot;</p>
  </li>
  <li><p>Sometimes the number is expressed in special character (Unicode?), ¼, ½ and ¾. How do I account for these?</p>
  </li>
  </ol>
  <p>I suspect the answer is to use regular expressions rather than a delimiter, but I could not really grasp how to use them yet.</p>