ozo,
That worked. Thanks!
Main Topics
Browse All TopicsI have hundreds of TXT files, in ASCII format, that have a lots of page-breaks that I want to remove or replace.
When I look at it in Windows Notepad, it just looks like a little vertical rectangle on its own line. As best I can tell from a hex viewer, the hex characters for this page-break are:
0D-0A 0C 0D 0A
I know how to do PCRE regex for a single hex character like
$string = preg_replace('/\x0A/', '\n', $string);
but I would prefer to do a full-replace of the whole page-break code (for example, to replace the whole thing with an empty string).
I don't know how to handle a hyphenated code e.g. "0D-0A" or a whole string of codes like 0D-0A 0C 0D 0A .
And because str_replace is faster than preg_replace, I hope there's a way to do it with str_replace.
Please advise.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
FrankTech,
If the suggestion above doesn't work or isn't enough could you upload a small sample of the text with those characters. You can zip the file and upload the zip file to www.ee-stuff.com , a site just for EE members. Let me know if you have a question or need more info on this. What is the hex viewer you used?
Most likely you will need to use a PHP function that will support an expression. I don't believe str_replace will.
Let me know if you have any questions or need more information.
b0lsc0tt
b0lsc0tt,
Thanks. I discovered that str_replace _does_ work for single hex characters if I use double quotes, like this:
$text = str_replace("\x0A", "", $text);
OR with combinations of single characters, like this:
$text = str_replace("\x0A\x0C\x0D"
but I couldn't get it to work with the hyphated character \x0A-\x0D . I wish it could, because that would be faster than preg_replace.
Yes, I didn't think of that possibility. That isn't really an expression still but is very helpful to remember. In a string that uses double quotes PHP will understand a number of "special characters." As you found out the \xHH is used for characters with a hex reference. Since the hexadecimal reference only allows 1 or 2 characters the hypenated one would have a problem. I am actually still curious as to what that charact is if it really is a single character. Oh, well. :)
If you are curious there is info on the other characters at http://us.php.net/manual/e
bol
Business Accounts
Answer for Membership
by: ozoPosted on 2007-11-07 at 15:31:04ID: 20237575
/[\x0A-\x0D]\x0C\x0D\x0A/