简体   繁体   中英

Regex result outputs single match for multiple matches

I'm having a file with multiple newlines at "Error message" field. I need to replace the newlines into space, so it can be loaded as single row.

But I'm unable to capture multiple matches. My regex outputs single match for the whole file. I need help to create regex which will give me 3 matches for the example provided.

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

Regex used

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

**Current File with Newlines : **

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

Expected Result :

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

Try matching:

\\n(Error Message=)

and substitute with

\\1

Add leading spaces in the substitution to suit your needs.

How about that?

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

Regex: https://regex101.com/r/DoED69/2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM