doc: add docment for UpperCamelCase

This commit is contained in:
dudaodong committed 2026-03-07 11:22:01 +08:00
1 parent de682f2214
commit ce3967b1d5
4 files changed
+76

No files matched your search

+35
View File
@@ -27,6 +27,7 @@ import (
- [Before](#Before)
- [BeforeLast](#BeforeLast)
- [CamelCase](#CamelCase)
- [UpperCamelCase](#UpperCamelCase)
- [Capitalize](#Capitalize)
- [IsString](#IsString)
- [KebabCase](#KebabCase)
@@ -265,6 +266,40 @@ func main() {
}
```
### <span id="UpperCamelCase">UpperCamelCase</span>
<p>将字符串转换为大写驼峰式字符串,首字母大写写, 非字母和数字会被忽略。</p>
<b>函数签名:</b>
```go
func UpperCamelCase(s string) string
```
<b>示例:<span style="float:right;display:inline-block;">[运行](https://go.dev/play/p/todo)</span></b>
```go
import (
"fmt"
"github.com/duke-git/lancet/v2/strutil"
)
func main() {
strings := []string{"", "foobar", "&FOO:BAR$BAZ", "$foo%", "Foo-#1😄$_%^&*(1bar"}
for _, v := range strings {
s := strutil.UpperCamelCase(v)
fmt.Println(s)
}
// Output:
//
// Foobar
// FooBarBaz
// Foo
// Foo11Bar
}
```
### <span id="KebabCase">KebabCase</span>
<p>将字符串转换为kebab-case, 非字母和数字会被忽略。</p>
+35
View File
@@ -27,6 +27,7 @@ import (
- [Before](#Before)
- [BeforeLast](#BeforeLast)
- [CamelCase](#CamelCase)
- [UpperCamelCase](#UpperCamelCase)
- [Capitalize](#Capitalize)
- [IsString](#IsString)
- [KebabCase](#KebabCase)
@@ -265,6 +266,40 @@ func main() {
}
```
### <span id="UpperCamelCase">UpperCamelCase</span>
<p>Coverts string to CamelCase string, non letters and numbers will be ignored.</p>
<b>Signature:</b>
```go
func UpperCamelCase(s string) string
```
<b>Example:<span style="float:right;display:inline-block;">[Run](https://go.dev/play/p/todo)</span></b>
```go
import (
"fmt"
"github.com/duke-git/lancet/v2/strutil"
)
func main() {
strings := []string{"", "foobar", "&FOO:BAR$BAZ", "$foo%", "Foo-#1😄$_%^&*(1bar"}
for _, v := range strings {
s := strutil.UpperCamelCase(v)
fmt.Println(s)
}
// Output:
//
// Foobar
// FooBarBaz
// Foo
// Foo11Bar
}
```
### <span id="KebabCase">KebabCase</span>
<p>KebabCase covert string to kebab-case, non letters and numbers will be ignored.</p>