note 102049 rejected from function.preg-replace by danbrown
| From: | danbrown@php.net | Date: | Tue, 25 Jan 2011 13:58:08 +0000 |
| Subject: | note 102049 rejected from function.preg-replace by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-176291@lists.php.net to get a copy of this message | ||
Note Submitter: cryptoncorp at gmail dot com
----
I have this code!
------------------------------------------------------------
<?php
$amount = $_POST['amount'];
// replace anything that's NOT 0-9 with "null" (nothing)
$result=preg_replace('/[^0-9^A-Z^a-z-*&%$ ,;_!@.{}#]/', '<br/>',
$amount);
echo $result;
?>
<form method="post" action="">
<input id="amount" name="amount" size="100"
type="textbox" value="Driver,.;_-{}*&%$#[] Genius Professional Edition
10.0.0.526/Driver Genius Professional Edition 10.0.0.526.exe">
<input type="submit" value="Submit">
</form>
------------------------------------------------------------
Output
------------------------------------------------------------
Driver,.;_-{}*&%$#
Genius Professional Edition 10.0.0.526
Driver Genius Professional Edition 10.0.0.526.exe
------------------------------------------------------------
The output i want
------------------------------------------------------------
Driver,.;_-{}*&%$#[] Genius Professional Edition 10.0.0.526
Driver Genius Professional Edition 10.0.0.526.exe
------------------------------------------------------------
Can someone help me with this! What i want is to add an exception for this []. But when i insert it
directly into my code it did not work for me! Please help me with this!