Skip to content

Commit

Permalink
📝 add description for cut function in strings.md
Browse files Browse the repository at this point in the history
  • Loading branch information
pikachu0310 committed Sep 26, 2024
1 parent bc513b7 commit 8116ee6
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions docs/cel/strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The API for this package was created based on Go's [`strings`](https://pkg.go.de
- [`containsAny`](#containsAny)
- [`containsRune`](#containsRune)
- [`count`](#count)
- [`cut`](#cut)
- [`cutPrefix`](#cutPrefix)
- [`cutSuffix`](#cutSuffix)
- [`equalFold`](#equalFold)
Expand Down Expand Up @@ -154,6 +155,30 @@ grpc.federation.strings.count("cheese", "e") //=> 3
grpc.federation.strings.count("five", "ve") //=> 1
```

## cut

`cut` slices the input string `s` into two substrings, `before` and `after`, separated by the first occurrence of the separator `sep`. If `sep` is not found, `before` will be set to `s` and `after` will be empty.

### Parameters

`cut(s string, sep string) []string`

- `s`: the string to cut.
- `sep`: the separator string.

### Returns

A list of two strings:
- The part of `s` before the first occurrence of `sep`.
- The part of `s` after the first occurrence of `sep`.

### Examples

```cel
grpc.federation.strings.cut("gophers", "ph") //=> ["go", "ers"]
grpc.federation.strings.cut("gophers", "x") //=> ["gophers", ""]
```

## cutPrefix

`cutPrefix` returns the string `s` after removing the provided `prefix`. If the string doesn't start with `prefix`, `s` is returned unchanged.
Expand Down

0 comments on commit 8116ee6

Please sign in to comment.