ID: 27257 Updated by: [EMAIL PROTECTED] Reported By: tokie at hanmail dot net -Status: Open +Status: Bogus Bug Type: Regexps related Operating System: Linux 2.4.x (Fedora core 1) PHP Version: 5.0.0b4 (beta4) New Comment:
Using correct regex would help: ereg_replace("[[:cntrl:]]", "*", $str); Previous Comments: ------------------------------------------------------------------------ [2004-02-14 20:03:05] tokie at hanmail dot net Description: ------------ I was handling some broken text file. And I managed to fix it by replacing the ascii-control characters (0x00 to 0x1F) to avoid crash when INSERT the text into a db-table. But the ereg_replace replaces other critical characters such as 0-9 : < = > ... (seems to be 0x30 to 0x3F), too. Reproduce code: --------------- $str = "<a href='http://www.php.net/'>PHP.net</a>"; $result = ereg_replace("[\\x00-\\x1F]", "*", $str); // the result was: // *a href*'http*//www.php.net/'*PHP.net*/a* // not, // <a href='http://www.php.net/'>PHP.net</a> Expected result: ---------------- the function should replace only the characters ranging 0x00 ~ 0x1F only. Actual result: -------------- it replaced not only 0x00 - 0x1F but also 0x30 ~ 0x3F (I guess, and 0x20 ~ 0x2F seems to be safe) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=27257&edit=1