Perl-compatible Regular Expression functions
| From: | Benjamin Berman | Date: | Tue, 23 May 2000 16:26:47 +0000 |
| Subject: | Perl-compatible Regular Expression functions | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-382@lists.php.net to get a copy of this message | ||
Has anyone out there tried to use the "preg_" functions on strings that
contain binary data? I basically have files that have a combination of
binary and text data, and I want to do search and replace on the text
part. Here's the way I've tried it in PHP:
(1) Read a file into a string with fread
(2) Do a search and replace on the string with "preg_replace"
(3) Write the string back to a file with fwrite
The fread and fwrite parts work fine with binary data. But the
"preg_replace" seems to mangle it (the string gets truncated). I know
that SED & Perl search and replace work fine with binary data like
this. Any ideas how to do it with PHP?
Thanks,
Ben Berman
benbfly@yahoo.com