String.Split("\n") ignore breaks in "quotes"

I’m trying to read from a text asset and make a array that holds each line of text. I do so by
linesInBank = dataBank.text.Split(’
However I want to ignore line breaks that occur within quotes. Is there a way to have split filter them out?

No, string.Split can’t do such an specific task. You have to split your strings manually.

Either iterate through the string char by char and apply your own exclusion logic, or use string.Split and afterwards check if there’s an odd number of quotation marks in a sub string. In this case you can re-merge the next sub strings (and reinsert the line break) until you find another odd number of quotation marks.

Either way, both require you to actually iterate through the string manually.

This would be a simple implementation in C#

// those are additionally needed:
using System.Collections.Generic;
using System.Text;

// [...]

public static string[] SplitExludeQuotes(string aText, char aSplitChar)
    StringBuilder sb = new StringBuilder();
    List<string> result = new List<string>();
    bool insideQuote = false;
    foreach (char c in aText)
        if (c == '"')
            insideQuote = !insideQuote;
        else if (c == aSplitChar)
            sb.Length = 0;
    return result.ToArray();