1

Im trying to split a string by a ;-character.
The only case where i have to ignore this is when ;-character is surrounded by Quotation marks from the both sides, like this ";"
So far i've managed to capture some of the cases with this code

Regex.Split(string, "(?=[^\"]);(?=[^\"])", RegexOptions.None)

but in a case when my string contains ;" combination (any char but the quotation mark, followed by semicolon, followed by quotation mark) the ;-character is also ignored wich shuold not be the case.


Could anyone point me in a right direction to how to ignore ; when it is surrounded by quotation marks from the both sides only?

here is a quick view of what my regex does: http://regexstorm.net/tester?p=(%3f%3d%5b%5e%5c%22%5d)%3b(%3f%3d%5b%5e%5c%22%5d)&i=%3b+%3b%0d%0a%22%3b%22%0d%0a%22%3b%0d%0a%3b%22

asdda ads
  • 11
  • 1
  • 7
    Use [CSV parser instead](http://stackoverflow.com/questions/6542996/how-to-split-csv-whose-columns-may-contain/6543418#6543418). – Wiktor Stribiżew Nov 27 '15 at 16:34
  • 2
    Try to find a regex that handles linebreaks inside the doublequotes. Or escaped doublequotes inside the doublequotes or, or, or. Real world csv's are more complex then a simple Regex can handle. I would also vote for a decent proven csv parser. – Ralf Nov 27 '15 at 16:43

0 Answers0