Splitting


String.Split

This can split a string into an array based on a single character separator

Dim arWords As String() 
arWords = System.String("this is my example").Split(New Char(){" "c})

For more complicated splitting or to split a string using more than a single character you need to use a regular expression.
If you pass in delimiters of both comma and space, any spaces after the commas will be treated as words.


Dim sString = "One,Two,Three Better Solutions, Ltd" 
Dim sDelimiters() As Char = {space, comma}
where space As Char = " "c
and comma As Char = ","c

vaResults = sString.Split(delimiters)
vaResults = {One, Two, Three, Better, Solutions, Ltd}

If you need to split in a more complicated way then you need to use a Regular Expression
For example if you wanted: 1) match a comma, 2) matach a space or 3) match a comma followed by a space



This inserts a substring into another string in a particular position.

sMyString.Insert(3,"text") 



© 2020 Better Solutions Limited. All Rights Reserved. © 2020 Better Solutions Limited TopPrevNext