views:

88

answers:

1

I'm using MagpieRSS to parse a Craigslist feed. The "title" field is:

***BUYING ALL BRAND NEW BLACKBERRY IN ANY QUANTITY BOLD~JAVELLIN~ONYX (Gramercy) $100000

and I'm using

if( preg_match( "/\(*\)*\d+$/", $title, $matches ) )

to figure out the price. $matches[0] should have the price, if I'm not mistaken. However, when I put it in my MySQL table (DOUBLE datatype), it comes in as 100. It seems to only take the first 3 digits after the $. I've run this through preg_match checkers all over the web, but nada.

Any thoughts?

+1  A: 

Your regex doesn't look like it should work. Given the following title:

***BUYING ALL BRAND NEW BLACKBERRY IN ANY QUANTITY BOLD~JAVELLIN~ONYX (Gramercy) $100000

If you wanted to just get the 100000 value, then I'd use:

/\$(\d+)$/
mopoke
The problem with this will be if there are other $'s in the string, no?
Shamoon
This will match any number after a dollar symbol at the end of a string only. Without knowing enough about the rest of your titles, I can't say how reliable it is. For example, if there are spaces between the symbol and the numbers (or other data between the numbers and the end of the string), then it won't match.
mopoke