Just simply loop thru the characters of the string step 2 and build your new string by appending the current 2 chars and a space to a stringbuilder object.
Some thing like this
Code:Dim originalString As String = "your original string here" Dim sb As New System.Text.StringBuilder() Dim length As Integer = originalString.Length If length >= 2 Then sb.Append(originalString.Substring(0, 2) & " ") For i As Integer = 2 To length - 1 Step 2 sb.Append(originalString.Substring(i, 2) & " ") Next If length Mod 2 <> 0 Then sb.Append(originalString(length - 1)) End If Else sb.Append(originalString & " ") End If Dim modifiedString As String = sb.ToString




Reply With Quote