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.
Input string (intentionally written ugly) is:
Berlin "New York"Madrid 'Frankfurt Am Main' Quebec Łódź München Seattle,Milano
Splitting code is:
Dim subStrings() As String = Regex.Split(myText, """([^""]*)""|,| ")
Result of this is:
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
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:
0)Berlin
1)New York
2)Madrid
3)Frankfurt Am Main
4)Quebec
5)Łódź
6)München
7)Seattle
8)Milano
So, please if someone know how to solve this concrete regex for me.
