Page 1 of 1

need to grab a number with a comma

Posted: Sat May 20, 2006 2:17 am
by jasondavis
I have a script which used to work as the numbers were a solid set of numbers, no commas. Now the numbers I am grabbing sometimes have a comma in them so it only grabs the numbers before the comma

Code: Select all

preg_match("/(\d+) friend/", $html, $msfc);

Re: need to grab a number with a comma

Posted: Sat May 20, 2006 8:01 am
by Chris Corbyn

Code: Select all

preg_match("/([\d,]+) friend/", $html, $msfc);

Posted: Sat May 20, 2006 9:36 pm
by jasondavis
that worked well thanks, 1 more thing now

I need to search for a friend(s) the ( and ) seem to mess it up how do you escape them or whatever need to be done

Code: Select all

friend(s)

Posted: Sun May 21, 2006 7:23 am
by Chris Corbyn
jasondavis wrote:that worked well thanks, 1 more thing now

I need to search for a friend(s) the ( and ) seem to mess it up how do you escape them or whatever need to be done

Code: Select all

friend(s)
Escape the parentheses with backslashes just like you do in other languages \( \).