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

+3
View File
@@ -1995,6 +1995,9 @@ import "github.com/duke-git/lancet/v2/strutil"
- **<big>CamelCase</big>** : coverts source string to its camelCase string.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/strutil.md#CamelCase)]
[[play](https://go.dev/play/p/9eXP3tn2tUy)]
- **<big>UpperCamelCase</big>** : coverts source string to its UpperCamelCase string.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/strutil.md#UpperCamelCase)]
[[play](https://go.dev/play/p/todo)]
- **<big>Capitalize</big>** : converts the first character of source string to upper case and the remaining to lower case.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/strutil.md#Capitalize)]
[[play](https://go.dev/play/p/2OAjgbmAqHZ)]
+3
View File
@@ -2002,6 +2002,9 @@ import "github.com/duke-git/lancet/v2/strutil"
- **<big>CamelCase</big>** : 将字符串转换为camelCase驼峰式字符串, 非字母和数字会被忽略。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/strutil.md#CamelCase)]
[[play](https://go.dev/play/p/9eXP3tn2tUy)]
- **<big>UpperCamelCase</big>** : 将字符串转换为CamelCase大写驼峰式字符串, 非字母和数字会被忽略。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/strutil.md#UpperCamelCase)]
[[play](https://go.dev/play/p/todo)]
- **<big>Capitalize</big>** : 将字符串的第一个字符转换为大写。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/strutil.md#Capitalize)]
[[play](https://go.dev/play/p/2OAjgbmAqHZ)]
+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>