1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-07 22:22:29 +08:00

fix: fix issue #275

This commit is contained in:
dudaodong
2024-12-04 16:37:46 +08:00
parent 0f9683a764
commit f58b706285
6 changed files with 182 additions and 7 deletions

View File

@@ -66,6 +66,7 @@ import (
- [Rotate](#Rotate)
- [TemplateReplace](#TemplateReplace)
- [RegexMatchAllGroups](#RegexMatchAllGroups)
- [Cut](#Cut)
<div STYLE="page-break-after: always;"></div>
@@ -1537,4 +1538,38 @@ func main() {
// [john.doe@example.com john.doe example com]
// [jane.doe@example.com jane.doe example com]
}
```
### <span id="Cut">Cut</span>
<p>Splits the string at the first occurrence of separator.</p>
<b>Signature:</b>
```go
func Cut(str, sep string) (before, after string, found bool)
```
<b>example:</b>
```go
import (
"fmt"
"github.com/duke-git/lancet/strutil"
)
func main() {
str := "hello-world"
before, after, found := strutil.Cut("hello-world", "-")
fmt.Println(before)
fmt.Println(after)
fmt.Println(found)
// Output:
// hello
// world
// true
}
```

View File

@@ -66,6 +66,7 @@ import (
- [Rotate](#Rotate)
- [TemplateReplace](#TemplateReplace)
- [RegexMatchAllGroups](#RegexMatchAllGroups)
- [Cut](#Cut)
<div STYLE="page-break-after: always;"></div>
@@ -1572,4 +1573,37 @@ func main() {
// [john.doe@example.com john.doe example com]
// [jane.doe@example.com jane.doe example com]
}
```
```
### <span id="Cut">Cut</span>
<p>分割字符串。</p>
<b>函数签名:</b>
```go
func Cut(str, sep string) (before, after string, found bool)
```
<b>示例:</b>
```go
import (
"fmt"
"github.com/duke-git/lancet/strutil"
)
func main() {
str := "hello-world"
before, after, found := strutil.Cut("hello-world", "-")
fmt.Println(before)
fmt.Println(after)
fmt.Println(found)
// Output:
// hello
// world
// true
}