.NET Regular Expression to split multiple words or phrases
Posted
by Cj Anderson
on Stack Overflow
See other posts from Stack Overflow
or by Cj Anderson
Published on 2010-03-19T15:36:02Z
Indexed on
2010/03/19
19:11 UTC
Read the original article
Hit count: 316
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)
© Stack Overflow or respective owner