簡體   English   中英

正則表達式結果輸出單個匹配項,多個匹配項

[英]Regex result outputs single match for multiple matches

我在“錯誤消息”字段中具有多個換行符的文件。 我需要將換行符替換為空格,因此可以將其作為單行加載。

但是我無法捕獲多個匹配項。 我的正則表達式輸出整個文件的單個匹配項。 我需要幫助來創建正則表達式,這將為我提供3個匹配的示例。

https://regex101.com/r/DoED69/1

正則表達式使用

^breakmantis.*;(Error;[\s\S]*;Regular;)[\s\S]*breakmantis

**帶換行符的當前文件:**

name;brand;environment;center;Error
breakmantis;Kordel;Production;Bleep Eyeglow;Error;"The message did not pass the validation: 
Error Message='PriceTag' is mandatory, under field Price.
Error Message='PriceAmount' is mandatory, under field Price.
Error Message='BaseQuantity' is mandatory, under field Price.";Regular;;;;24 Apr 2019 14:34 CEST
breakmantis;Kordel;Production;Bleep Eyeglow;Error;"The message did not pass the validation: 
Error Message='PriceTag' is mandatory, under field Price.
Error Message='PriceAmount' is mandatory, under field Price.
Error Message='BaseQuantity' is mandatory, under field Price.";Regular;;;;24 Apr 2019 14:35 CEST
breakmantis;Kordel;Production;Bleep Eyeglow;Error;"The message did not pass the validation: 
Error Message='PriceTag' is mandatory, under field Price.
Error Message='PriceAmount' is mandatory, under field Price.
Error Message='BaseQuantity' is mandatory, under field Price.";Regular;;;;24 Apr 2019 14:36 CEST

預期結果 :

breakmantis;Kordel;Production;Bleep Eyeglow;Error;"The message did not pass the validation: Error Message='PriceTag' is mandatory, under field Price.Error Message='PriceAmount' is mandatory, under field Price.Error Message='BaseQuantity' is mandatory, under field Price.";Regular;;;;24 Apr 2019 14:34 CEST
breakmantis;Kordel;Production;Bleep Eyeglow;Error;"The message did not pass the validation: Error Message='PriceTag' is mandatory, under field Price.Error Message='PriceAmount' is mandatory, under field Price.Error Message='BaseQuantity' is mandatory, under field Price.";Regular;;;;24 Apr 2019 14:35 CEST
breakmantis;Kordel;Production;Bleep Eyeglow;Error;"The message did not pass the validation: Error Message='PriceTag' is mandatory, under field Price.Error Message='PriceAmount' is mandatory, under field Price.Error Message='BaseQuantity' is mandatory, under field Price.";Regular;;;;24 Apr 2019 14:36 CEST

嘗試匹配:

\\ n(錯誤消息=)

並用

\\ 1

在替換中添加前導空格以適合您的需求。

那個怎么樣?

^breakmantis.*;(Error;[\\s\\S]*?)CEST$

正則表達式: https : //regex101.com/r/DoED69/2

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM