Re: Quick ereg_replace question
| From: | Lowell Allen | Date: | Tue, 02 Dec 2003 18:59:16 +0000 |
| Subject: | Re: Quick ereg_replace question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-171600@lists.php.net to get a copy of this message | ||
> I need a regular expression which will eliminate all characters except
> numbers, period, and +, -, *, or /
>
> I am currently using:
> $new_value = ereg_replace('[^0-9\.-/+*]', "", $value);
>
> However, this seems to eliminate - as well. Any help would be appreciated.
Try listing the - as the first character (or last) so it's not seen as
showing a range.
> Also, any good references for regular expressions?
O'Reilly's "Mastering Regular Expressions", by Jeffrey Friedl.
HTH
--
Lowell Allen