Any questions involving matching text strings to patterns - the pattern is called a "regular expression."
Moderator: General Moderators
jasondavis
Forum Commoner
Posts: 60 Joined: Sat Feb 04, 2006 5:35 pm
Post
by jasondavis » Sat May 20, 2006 2:17 am
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);
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Sat May 20, 2006 8:01 am
Code: Select all
preg_match("/([\d,]+) friend/", $html, $msfc);
jasondavis
Forum Commoner
Posts: 60 Joined: Sat Feb 04, 2006 5:35 pm
Post
by jasondavis » Sat May 20, 2006 9:36 pm
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
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Sun May 21, 2006 7:23 am
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
Escape the parentheses with backslashes just like you do in other languages \( \).