how to split a string at positions before a character?
the obvious way doesn't work:
>>> h=re.compile("(?=a)") >>> h.split("fffagggahhh") ['fffagggahhh'] >>>
Ok, not exactly the solution you want but I thought it will be a useful addition to problem here.
Solution without re
>>> x = "fffagggahhh" >>> k = x.split('a') >>> j = [k] + ['a'+l for l in k[1:]] >>> j ['fff', 'aggg', 'ahhh'] >>>