I have a string which is in capitals "JIM O'CONNOR" and I want to convert it to
"Jim O'Connor"
Is there any special Libraries or Functions for doing this?
Sub Activity_Create(FirstTime As Boolean)
Dim s As String
s = ToMixCase("some string value")
MsgBox(s, "")
End Sub
Sub ToMixCase(Entry As String) As String
Dim sb As StringBuilder
Dim m As Matcher
Dim I As Int
Entry = Entry.ToLowerCase
sb.Initialize
m = Regex.Matcher("(^\w)|(\s\w)", Entry)
Do While m.Find
If m.Match.Length > 1 Then
sb.Append(Entry.SubString2(I, m.GetStart(0) + 1))
sb.Append(m.Match.SubString(1).ToUpperCase)
Else
sb.Append(Entry.SubString2(I, m.GetStart(0)))
sb.Append(m.Match.ToUpperCase)
End If
I = m.GetEnd(0)
Loop
If I < Entry.Length Then
sb.Append(Entry.SubString(I))
End If
Return sb.ToString
End Sub
Dim txt, s, sOrig As String
Dim i as Int
Cursor1=SQL1.ExecQuery("SELECT MyCol FROM MyTable")
Cursor1.Position=0
For i=0 To Cursor1.RowCount-1
Cursor1.Position=i
sOrig=Cursor1.GetString("MyCol")
s=ToMixCase(sOrig) 'executes NJDude's sub
txt="UPDATE MyTable SET MyCol = ? WHERE MyCol = ?"
SQL1.ExecNonQuery2(txt,Array As String(s,sOrig))
Next
I appreciate your donation.Donation made as well - only a small one, but hopefully well received. Cheers