RE: [PHP] Re: Ereg problems
| From: | Jeff McKeon | Date: | Fri, 26 Mar 2004 13:18:37 +0000 |
| Subject: | RE: [PHP] Re: Ereg problems | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-181552@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Curt Zirzow [mailto:czirzow@yahoo.com]
> Sent: Thursday, March 25, 2004 6:55 PM
> To: php-general@lists.php.net
> Subject: [PHP] Re: Ereg problems
>
>
> On Thu, 25 Mar 2004 18:31:02 -0500, Jeff McKeon
> <jmckeon@telaurus.com>
> wrote:
>
> > Having some problems with ereg()
> >
> > [begin code]
> >
> > $string="Credit adjusted: $-1.32 to $48.68"
> >
> > ereg("([\\$(\\$-)][0-9]+\.[0-9]+)",$data[2],$found);
> >
> > While(list($index,$hits)=each($found))
> > {
> > echo "$index , $hits<br>";
> > }
> > [end code]
>
> you assigned $string but used $data[2]?
>
whoops, that was a leftover from the actual app that was parsing
a field pulled from a database query. Forgot to correct that when I
posted.
>
> I would suggest using pcre instead of Posix:
>
> preg_match_all('($-?[0-9]+\.[0-9]+)', $string, $found);
> print_r($found);
>
That produces:
Array ( [0] => Array ( ) ) 0 , Array
>
> Curt.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>