Re: Perl-compatible Regular Expression functions
| From: | Benjamin Berman | Date: | Tue, 23 May 2000 19:27:47 +0000 |
| Subject: | Re: Perl-compatible Regular Expression functions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-396@lists.php.net to get a copy of this message | ||
ereg_replace seems to have the same problem.
ben.
Benjamin Berman wrote:
> 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