我有一個正則表達式串後面的正則表達式
$pattern = '/\b\d{4}-\d{4}\b/';
preg_match($pattern, $text, $matches);
我需要的正則表達式後獲得5個詞語。任何想法,我會如何做到這一點?
例如「Power Slot Slotted Rotors - 1997-1998 Oldsmobile Regency - Brakes & Brake Pads - Brake Rotors。」
我需要返回「1997-1998奧茲莫比爾攝政 - 剎車&」;
任何想法?
//從底部評論更新。
一個字符串中可能有多個匹配項。例如
「例如:」2000-2009 Ford Explorer,2000-2010 Ford Ranger。 1674SJT JBA Cat4ward頭功能」
我仍然在試圖讓一5‘的數字序列爲xxxx-xxxx後非白色空間’。
那*不是*「之後的5個單詞......那是**匹配和**之後的5個單詞」 – freefaller 2012-08-03 08:49:31
另外如果我們''''''''''和'&'在技術上不是*詞* * – DaveRandom 2012-08-03 08:50:48
@DaveRandom作爲迂腐你必須說' - '和'&'從技術角度來看,確實如此:-) – arkascha 2012-08-03 08:51:51