I have a binary file that I would like to regex search/replace hex bytes within it. I know there are command line methods for achieving this with Perl, however, if there's a way to do this with Objective-C/Cocoa I haven't been able to find it. The Perl method from the command line in OSX which works fine, although I would like to incorporate such in a Cocoa application - thanks
Binary file: TEST
45 76 65 6E 20 69 66 20 79 6F 75 20 66 61 6C 6C 20 6F 6E 20 79 6F 75 72 20 66 61 63 65 2C 20 79 6F 75 27 72 65 20 73 74 69 6C 6C 20 6D 6F 76 69 6E 67 20 66 6F 72 77 61 72 64 2E 20
Bytes to replace: 66 61 63 Replace with: 61 72 73
Perl example:
# grep -Z -r -l face TEST | xargs -0 perl -pi -e "s/\x66\x61\x63/\x61\x72\x73/g"