我有三個工作正則表達式模式幾個正則表達式模式(不是有些海峽,任何文字,日期):加入
^(sezon\s[0-9]+) => finds if string starts with sezon $$ where $is digit
([a-zA-z]*|\b)*.* => that should match any words
\d{1,2}[.]\d{1,2}[.]\d{2,4} => that matches date
現在我想否定第一和第三模式和它們連接成第二。
Sezon 2 some text here 03.02.1203 => should be excluded
Sezon more text => included
Sezon 2 mote set amet => excluded
some date here 20.20.2222 =>excluded
only text here also => included
2 - => excluded
我試圖做到的,是否認與字符串:
- 日期末,
- Sezon $開頭
- 1 - 開頭
休息(Sezon一些文字)(只有文本)應該被接受
現在我可以做3個preg_matches,然後將它們的輸出結合在'if'中,但是我想知道它是否可以在一種模式下完成。或者完全不同的想法?其將被用於
實串: sezon 1
1 -
Pilot (pilot)
26.10.2015
2 -
Stronger Together
2.11.2015
3 -
Fight or Flight
9.11.2015
行由爆炸功能破壞。 對於每一行字符串,我想檢查它的季節,數字,標題或日期,然後在每種情況下做不同的事情。
第二種模式是完全錯誤的,因爲它匹配任何字符串。 –
我會說模式2可以簡化爲'。*'。 –
它應該匹配其他東西之間的任何文本字符串。這就是爲什麼我要將三種模式合併到一個 – Mike