我有串這樣ClientLovesProcess
我需要除了第一個大寫字母每個大寫字母之間添加一個空格,因此最終的結果會是這樣Client Loves Process
添加uppsercase字母
我不認爲golang具有之間的空間最好的字符串支持,但是這是我在想繞了:
首先遍歷每個字母的所以是這樣的:
name := "ClientLovesProcess"
wordLength := len(name)
for i := 0; i < wordLength; i++ {
letter := string([]rune(name)[i])
// then in here I would like to check
// if the letter is upper or lowercase
if letter == uppercase{
// then break the string and add a space
}
}
問題是我不知道如何來檢查字母較低或者大寫。我檢查了字符串手冊,但他們沒有一些有它的功能。什麼是另一種方法來完成這項工作呢?