I've got a CSV file which gives problems importing because of the fields containing new line characters. As CSV importers treat every newline as a new row, the newlines in the fields mess things up.
So I want to replace every newline within double quotes with <br>
leaving the 'real' newlines outside double quotes untouched.
First step would be to be able to create a regexp to get the newlines within the text file.
(\n|\r)
But after this I get lost, because I can't find the xxx within this expression:
(")(xxx)(\n|\r)(xxx)(")
And a solution to let the 'real' newlines untouched.
Concluding: How can I replace every newline within a field, enclosed by double quotes with a <br>
I'm now using sublime text to test the regex but later it will be used in a php application.
Search pattern:
("[^"\n]*)\r?\n(?!(([^"]*"){2})*[^"]*$)
Replacement Pattern:
$1<br>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With