title: Split affixes to prefix, root and suffix using python
body: <p>I have a text file called for_split.txt file that has the following content on it:</p>
  <pre><code>malam
  ba-calle
  pem-porut#an
  daun #kulu
  arau/araw
  imbaw//nimbaw
  dengo | nengo
  dodop=am
  {di} dalam
  di {dalam}
  +meri [b]
  </code></pre>
  <p>I use the following script to to split them:</p>
  <pre><code>import sys
  sys.stdout = open('final_result.txt', 'w')
  
  import re
  with open('a.txt') as f:
  new_split = [item.strip() for item in f.readlines()]
  
  for word in new_split:
  m = re.match(r&quot;(?:\{[^-#={}/|]+\})?(?:([^-#={}/|]+)-)?([^-#={}/|]+)(?:/[^-#={}/|]+)?(?:[#=]([^-#={}/|]+))?&quot;, word)
  if m:
      print(&quot;\t&quot;.join([str(item).lstrip() for item in m.groups()]))
  else:
      print(&quot;(no match: %s)&quot; % word)
  </code></pre>
  <p>the result looks like bellow:</p>
  <pre><code>None    malam   None
  ba  calle   None
  pem porut   an
  None    daun    kulu
  None    arau    None
  None    imbaw   None
  None    dengo   None
  None    dodop   am
  None    dalam   None
  None    di  None
  None    +meri [b]   None
  </code></pre>
  <p>that works pretty good for the others but It didn't work for the last words which is +meri [b] it should take the meri to root and the [b] to suffix instead of</p>
  <pre><code>None    +meri [b]   None
  </code></pre>
  <p>there should be</p>
  <pre><code>None +meri [b]
  </code></pre>
  <p>it should ignore the + from the beginning of meri and keep the meri to root and [b] to suffix is there any advice for this please? should I change my script to get the result can any one please help me with that thanks.</p>