You could just match non-|
characters and use lookarounds to make sure it's the element before Ab Initio...
:
re.search(r'(?<=[|])[^|]*(?=[|]Ab Initio Software)', name, re.IGNORECASE).group()
Even without the lookahead, if you just change (.*?)
to the more explicit [^|]*
, you'd get the right result. But the greedy lookahead solution might be more efficient. Anyway, here it is:
re.search(r'[|]([^|]*)[|]Ab Initio Software', name, re.IGNORECASE).group(1)