The problem is with \x01 at the end, consuming the \x01 delimiter, which leads to the fact that the pattern always fails in a key-value pair adjacent to one just matched, since none of (?:^|\x01) coincide.
Using this substring of your input as an example, the mapping to new_order_finder3 :
\x0154=1\x0155=AAPL.O\x01 ------------ X
As you can see, after he managed to match the key-value pair 54=1 , he also consumes \x01 , and the adjacent key-value pair can never be matched.
There are several ways to solve this problem. One solution is to put \x01 at the end of the pending statement so that we can make sure that \x01 completes the key-value pair without consuming it:
new_order_finder3 = re.compile("(?:^|\x01)(11|15|35|38|54|55)=(.*?)(?=\x01)")
Now the output contains all the expected fields:
{'11': 'N09080243', '38': '2100', '15': 'USD', '55': 'AAPL.O', '54': '1', '35': 'D'}
source share