What does this have to do with regexes?
And are you saying that your example is a match, even though the lines are different?
Maybe you should post your python code.
> I used Python and it is incredibly slow... for a 2G text file it takes days...
Python isn't that horribly inefficient.
For sure, just translating what you have into C++ won't magically transform 'days' into 'seconds'.
What you need is a better algorithm, not a different implementation.
Post a more meaningful example of your input files and your python code, and perhaps we can see what you're actually trying to do.