preg_match help required
I am trying to get some values from the following line...
$txt = 'Auction Type: BuyNow, Auction End Time: 09/20/2011 09:00 AM (PDT), Asking Price/Current Bid: $5, Number of Bids: 0, Domain Age: 1, Description: , Traffic: 0, Valuation: $0, IsAdult: false';
preg_match('/(Auction E开发者_开发问答nd Time: )(.*)( \(PDT\), Asking Price\/Current)/', $txt, $expiring);
I am currently getting $expiring(Auction End Time) only, but I need to get Number of Bids: as well, how should I update it to get results? Please help.
preg_match("/Auction End Time: ([^,]*),.*?Number of Bids: ([0-9]+),/",$txt,$m);
// $m[1] == end time (including timezone)
// $m[2] == number of bids
I fixed the first one too, because if the decription happened to contain (PDT)
then it would have broken your regex.
How about something like this?
/Auction End Time: (.*)\(.*Number of Bids: (\d+)/
精彩评论