.NET Regular Expression to split multiple words or phrases
- by Cj Anderson
I'm using the code below to take a string and split it up into an array. It will take: Disney Land and make it two separate elements. If the string contains "Disney Land" then it is one element in the array. Works great, however it adds some empty elements to the array each time. So I just iterate over the elements and remove them if they are empty. Is there a tweak to the code below that will prevent those empty elements from occurring?
Private m_Reg As Regex
m_Reg = New Regex("([^""^\s]+)\s*|""([^""]+)""\s*")
Dim rezsplit = m_Reg.Split(criteria)