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:
@@ -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
|
||||
}
|
||||
```
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user