To count quickly until first match and stop in megastring

I want to count number of characters until the pattern ffffffff57 in megarow (do not read data forward from that point) such that you do not read the whole megarow in in memory.
It should return 120.

Megastring Data

48000000fe5a1eda480000000d00030001000000cd010000020000000000000000000000000000000000000000000000000000000200000001000000ffffffff57ea5e55ff640c00585e0000fe5a1eda480000000d00030007000000cd010000010000000000000002000000000000800000000000000000000000

How can you count quickly until the first match?


Source: unix

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.