我有這個字符串需要使用pregmatch
配套齊全的自包含的,以從字符串中提取日期2間臥室的套房僅5分鐘步行至UVIC適用於9月1日
現在我使用pregmatch提取它:這是正則表達式。
'/\bavailable\\s(?P<date_available>[?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|Jun(?:e)|Jul(?:y)?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?|immediately]+[\\s\d]+)[st|nd|rd|th]?/i'
目前這個表達式可以從字符串中提取:
Available september 1st.
Available September 2nd
available september 3rd
available september 4th
available sept 1
輸出的例子是:
Array
(
[0] => available September 1
[date_available] => September 1
[1] => September 1
)
但我不能找到一種方法,當琴絃提取:
Available for september 1st.
Available in September 2nd
available since september 3rd
available at september 4th
任何人可以幫我處理這個問題嗎?感謝
難道你不能只改變'available'到'available \ s +(for | in | at | since |)\ s *'? – h2ooooooo
感謝您的想法。 。 ;) –