Quentin Geff
Quentin Geff

Reputation: 829

Regular expression to capture line terminators in a CSV field

I 've a field "comment" in a csv file who can contains any char and several lines.

Example :

firstname;lastname;comment toto;titi;"Hi, you ok ? yes and you ?" pierre;tutu;"nice; i love that." foo;bar;"ko ""lol""" michu;ferro;"ok "" but it's strange """

i need to inline each csv records.

Expected :

firstname;lastname;comment toto;titi;"Hi, you ok ? yes and you ?" pierre;tutu;"nice; i love that." foo;bar;"ko ""lol""" michu;ferro;"ok ""but it's strange"""

i tried something like that : https://regex101.com/r/SzJuUl/1 in vain. Someone can help me ?

Thanks

Upvotes: 0

Views: 56

Answers (1)

chirag sanghvi
chirag sanghvi

Reputation: 892

(?<!")\n

It lookout for new line that is not preceded by '"'. Hope it helps.

Upvotes: 1

Related Questions