title: vb.net Split string with regex
body: <p>I have requrement to split a string with regex on several rules and I do something with help of previous posts here but I don't know how to do it completelly. </p>
  
  <p>Input string (intentionally written ugly) is:</p>
  
  <pre><code>Berlin "New York"Madrid 'Frankfurt Am Main' Quebec Łódź   München Seattle,Milano
  </code></pre>
  
  <p>Splitting code is:</p>
  
  <pre><code>Dim subStrings() As String = Regex.Split(myText, """([^""]*)""|,| ")
  </code></pre>
  
  <p>Result of this is:</p>
  
  <pre><code>0)  
  1)  
  2)Berlin  
  3)  
  4)New York  
  5)Madrid  
  6)'Frankfurt  
  7)Am  
  8)Main'  
  9)Quebec  
  10)Łódź  
  11)  
  12)  
  13)München  
  14)Seattle  
  15)Milano  
  </code></pre>
  
  <p>In short, string should be splitted into array by " " (space) and/or "," char and/or by single or double quote. Quoted terms should be treated as a single word. This means that term in single quotes (at place 6) will be treated a same like a term in double quotes. That way 'Frankfurt Am Main' at place 6. will be "one word" same as is "New York" at place 4. Also, I would like if regex can be made that empty matches would not go to subStrings() array. After all an ideal result from given example should be:   </p>
  
  <pre><code>0)Berlin  
  1)New York  
  2)Madrid  
  3)Frankfurt Am Main  
  4)Quebec  
  5)Łódź  
  6)München  
  7)Seattle  
  8)Milano  
  </code></pre>
  
  <p>So, please if someone know how to solve this concrete regex for me.</p>