2012-05-09 66 views
0

我希望有人可以用這個正則表達式來幫助我。我只用它來收集字符串中的單個單詞,所以我不知道如何處理多行和看起來像ASCII字符。用特殊字符表示多行的正則表達式

這裏是文本塊:

Information  - RETAILEAITRT00003 - Traitement  - Processing  - ---> Recovery from 05/09/2012 at 09:17:50 AM 

Information  - RETAILEAITRT00020 - Traitement  - Processing  - ---> Information recovery starts on 05/09/2012 at 09:17:50 AM 

Information  - RETAILEAITRT00021 - Traitement  - Processing  - ----> File processing: C:\Program Files (x86)\Prog\Prog RIT\Web Orders\live\Prog Import\Order_110039354.tab 
Information  - RETAILEAITRT00005 - Traitement  - Processing  - ---> End of information recovery on 05/09/2012 at 09:17:51 AM 
Information  - RETAILEAITRT00006 - Traitement  - Processing  - -> 6 records read 
Information  - RETAILEAITRT00008 - Traitement  - Processing  - -> 6 records processed 
Information  - RETAILEAITRT00010 - Traitement  - Processing  - -> 6 integrated records 
Information  - RETAILEAITRT00015 - Traitement  - Processing  - -> No integration errors 

Information  - RETAILEAITRT00020 - Traitement  - Processing  - ---> Information recovery starts on 05/09/2012 at 09:17:51 AM 

Information  - RETAILEAITRT00021 - Traitement  - Processing  - ----> File processing: C:\Program Files (x86)\Prog\Prog RIT\Web Orders\live\Prog Import\Order_110039355.tab 
Third-party  - : La raison sociale doit �tre renseign�e 
Third-party  - _SHIP : La raison sociale doit �tre renseign�e 
Erreur   - RETAILEAIDOC00008 - Document   - Document   - address The internal reference enables the recovery of a document. It is mandatory 
Erreur   - RETAILEAIDOC00008 - Document   - Document   - address The internal reference enables the recovery of a document. It is mandatory 
Information  - RETAILEAITRT00005 - Traitement  - Processing  - ---> End of information recovery on 05/09/2012 at 09:17:52 AM 
Information  - RETAILEAITRT00006 - Traitement  - Processing  - -> 4 records read 
Information  - RETAILEAITRT00008 - Traitement  - Processing  - -> 4 records processed 
Information  - RETAILEAITRT00012 - Traitement  - Processing  - -> No records integrated 
Information  - RETAILEAITRT00013 - Traitement  - Processing  - -> 4 records contain errors 

Information  - RETAILEAITRT00003 - Traitement  - Processing  - ---> Recovery from 05/09/2012 at 09:33:03 AM 

Information  - RETAILEAITRT00020 - Traitement  - Processing  - ---> Information recovery starts on 05/09/2012 at 09:33:03 AM 

Information  - RETAILEAITRT00021 - Traitement  - Processing  - ----> File processing: C:\Program Files (x86)\Prog\Prog RIT\Web Orders\live\Prog Import\Order_110039356.tab 
Information  - RETAILEAITRT00005 - Traitement  - Processing  - ---> End of information recovery on 05/09/2012 at 09:33:05 AM 
Information  - RETAILEAITRT00006 - Traitement  - Processing  - -> 6 records read 
Information  - RETAILEAITRT00008 - Traitement  - Processing  - -> 6 records processed 
Information  - RETAILEAITRT00010 - Traitement  - Processing  - -> 6 integrated records 
Information  - RETAILEAITRT00015 - Traitement  - Processing  - -> No integration errors 

Information  - RETAILEAITRT00020 - Traitement  - Processing  - ---> Information recovery starts on 05/09/2012 at 09:33:05 AM 

Information  - RETAILEAITRT00021 - Traitement  - Processing  - ----> File processing: C:\Program Files (x86)\Prog\Prog RIT\Web Orders\live\Prog Import\Order_110039357.tab 
Information  - RETAILEAITRT00005 - Traitement  - Processing  - ---> End of information recovery on 05/09/2012 at 09:33:06 AM 
Information  - RETAILEAITRT00006 - Traitement  - Processing  - -> 6 records read 
Information  - RETAILEAITRT00008 - Traitement  - Processing  - -> 6 records processed 
Information  - RETAILEAITRT00010 - Traitement  - Processing  - -> 6 integrated records 
Information  - RETAILEAITRT00015 - Traitement  - Processing  - -> No integration errors 

但是,我只希望這一段:

Information  - RETAILEAITRT00020 - Traitement  - Processing  - ---> Information recovery starts on 05/09/2012 at 09:17:51 AM 

Information  - RETAILEAITRT00021 - Traitement  - Processing  - ----> File processing: C:\Program Files (x86)\Prog\Prog RIT\Web Orders\live\Prog Import\Order_110039355.tab 
Third-party  - : La raison sociale doit �tre renseign�e 
Third-party  - _SHIP : La raison sociale doit �tre renseign�e 
Erreur   - RETAILEAIDOC00008 - Document   - Document   - address The internal reference enables the recovery of a document. It is mandatory 
Erreur   - RETAILEAIDOC00008 - Document   - Document   - address The internal reference enables the recovery of a document. It is mandatory 
Information  - RETAILEAITRT00005 - Traitement  - Processing  - ---> End of information recovery on 05/09/2012 at 09:17:52 AM 
Information  - RETAILEAITRT00006 - Traitement  - Processing  - -> 4 records read 
Information  - RETAILEAITRT00008 - Traitement  - Processing  - -> 4 records processed 
Information  - RETAILEAITRT00012 - Traitement  - Processing  - -> No records integrated 
Information  - RETAILEAITRT00013 - Traitement  - Processing  - -> 4 records contain errors 

也有出現奇怪的問號一些特殊的字符存在。我真的不知道從哪裏開始。我想它必須尋找^ Erreur,然後抓住它上面和下面的線條,直到找到帶有空格的^ ...?

感謝

+0

這不是特別清楚你的C開始至少一行比賽的標準是。你說上下查找,直到找到一個帶有空格的行,但在上面的示例中,它包含第一個僅限空白行的行。比賽有什麼定義標準? – jmar777

+0

這是三個條目..兩個沒有錯誤,然後一個之間有一個錯誤。每個條目始終以「信息恢復開始」一行開始。如果出現錯誤,我希望整個塊返回。 – Samuurai

回答

0

我能得到這個與下面的正則表達式的工作:

Information.+recovery starts.+\n\n(?:.+\n)+(?:Erreur.+\n)+(?:.+\n)+ 

注:這需要使用的 「G」(global)標誌(successfuly測試在JavaScript中)。不知道您正在使用哪種語言,但它應該有一個等效的標誌。

是的,這是非常難看:)。這基本上就是它的尋找:

  • 以「信息」開始,包括單詞的行「開始復甦」
  • 後跟一個空行
  • 隨後至少一個通用線
  • 其次,隨着「ERREUR」
  • 後跟任何連續的,非空白,只有線
+0

非常好!你真的讓我起來和跑步。我沒有讓你的工作完全一樣。我做了一些相關的研究和思考,並提出了這個問題:信息+恢復開始。+ \ n(?:。+ \ n){5} Erreur(?:。+ \ n)(?: 。+ \ n){5} - 有點僵化,但我會測試它,它應該做的伎倆。再次感謝! – Samuurai

+0

很高興你能工作! – jmar777