in reply to Re: Searching binary data
in thread Searching binary data

I think you want ".", rather then "\S" in your regex. Also, I think your matching code will miss cases where there is more then one match per line.

However, the basic idea of packing is exactly what you want. You also probably want to use ord and printf %x to print your results in hex. (or unpack).


We are using here a powerful strategy of synthesis: wishful thinking. -- The Wizard Book

Replies are listed 'Best First'.
Re: Re: Re: Searching binary data
by Juerd (Abbot) on Mar 14, 2002 at 17:58 UTC

    I think you want ".", rather then "\S" in your regex

    I copied that from the original post. I have no idea what sort of file is being used.

    Also, I think your matching code will miss cases where there is more then one match per line.

    The inner while (the statement modifier) takes care of that.

    U28geW91IGNhbiBhbGwgcm90MTMgY
    W5kIHBhY2soKS4gQnV0IGRvIHlvdS
    ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
    geW91IHNlZSBpdD8gIC0tIEp1ZXJk
    

      Whoops, missed the statement modifer while; reading code too quickly while doing other things at the same time.

      As to using \S vs ., in your code it's matching arbitrary random data. In his, it's maching hex, so it's known nonspace.


      We are using here a powerful strategy of synthesis: wishful thinking. -- The Wizard Book