Split phrases delimited by multiple white spaces
Provided by: FMS Development Team
Lots of times we want to split strings based on white space
but we have to write extra code to ensure that there are no multiple white
spaces. Splitting a string with consecutive multiple white spaces returns an
array with empty string(s).
One can avoid writing extra code by simply using the
function Regex.Split in the System.Text.RegularExpression namespace. This
function Splits the specified input string at the positions defined by a
regular expression pattern. The VB.Net code would look something like this:
Dim
arrWords() As String = _
System.Text.RegularExpressions.Regex.Split(strPhrase, "\s+")
Return to the tips page
|