From ce3967b1d514678e7647b99eacb726682842bad4 Mon Sep 17 00:00:00 2001 From: dudaodong Date: Sat, 7 Mar 2026 11:22:01 +0800 Subject: [PATCH] doc: add docment for UpperCamelCase --- README.md | 3 +++ README_zh-CN.md | 3 +++ docs/api/packages/strutil.md | 35 +++++++++++++++++++++++++++++++++ docs/en/api/packages/strutil.md | 35 +++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+) diff --git a/README.md b/README.md index 6ab5f33..71f033d 100644 --- a/README.md +++ b/README.md @@ -1995,6 +1995,9 @@ import "github.com/duke-git/lancet/v2/strutil" - **CamelCase** : 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)] +- **UpperCamelCase** : 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)] - **Capitalize** : 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)] diff --git a/README_zh-CN.md b/README_zh-CN.md index 566b81d..0750934 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -2002,6 +2002,9 @@ import "github.com/duke-git/lancet/v2/strutil" - **CamelCase** : 将字符串转换为camelCase驼峰式字符串, 非字母和数字会被忽略。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/strutil.md#CamelCase)] [[play](https://go.dev/play/p/9eXP3tn2tUy)] +- **UpperCamelCase** : 将字符串转换为CamelCase大写驼峰式字符串, 非字母和数字会被忽略。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/strutil.md#UpperCamelCase)] + [[play](https://go.dev/play/p/todo)] - **Capitalize** : 将字符串的第一个字符转换为大写。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/strutil.md#Capitalize)] [[play](https://go.dev/play/p/2OAjgbmAqHZ)] diff --git a/docs/api/packages/strutil.md b/docs/api/packages/strutil.md index 8252bfe..953ab61 100644 --- a/docs/api/packages/strutil.md +++ b/docs/api/packages/strutil.md @@ -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() { } ``` +### UpperCamelCase + +

将字符串转换为大写驼峰式字符串,首字母大写写, 非字母和数字会被忽略。

+ +函数签名: + +```go +func UpperCamelCase(s string) string +``` + +示例:[运行](https://go.dev/play/p/todo) + +```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 +} +``` + ### KebabCase

将字符串转换为kebab-case, 非字母和数字会被忽略。

diff --git a/docs/en/api/packages/strutil.md b/docs/en/api/packages/strutil.md index 90e2d99..8392953 100644 --- a/docs/en/api/packages/strutil.md +++ b/docs/en/api/packages/strutil.md @@ -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() { } ``` +### UpperCamelCase + +

Coverts string to CamelCase string, non letters and numbers will be ignored.

+ +Signature: + +```go +func UpperCamelCase(s string) string +``` + +Example:[Run](https://go.dev/play/p/todo) + +```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 +} +``` + ### KebabCase

KebabCase covert string to kebab-case, non letters and numbers will be ignored.