可能重複:
How do I make part of a regular expression optional in Ruby?正則表達式匹配可選條件
我試圖建立與rubular一個正則表達式匹配:
On Feb 23, 2011, at 10:22 , James Bond wrote:
OR
On Feb 23, 2011, at 10:22 AM , James Bond wrote:
這是我到目前爲止,但由於某種原因,它不匹配?想法?
(On.* (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{1,2}, [12]\d{3}.* at \d{1,2}:\d{1,2} (?:AM|PM),.*wrote:)
如何使AM/PM文本可選?既可以匹配AM/PM,也可以不匹配?
單詞「正則表達式」是小寫,而不是全部大寫。 – 2011-02-27 21:58:54