https://github.com/mamal72/stringish
A set of chain-able string helpers to reduce the pain of manipulating strings
https://github.com/mamal72/stringish
go golang string string-manipulation strings
Last synced: 5 months ago
JSON representation
A set of chain-able string helpers to reduce the pain of manipulating strings
- Host: GitHub
- URL: https://github.com/mamal72/stringish
- Owner: mamal72
- License: mit
- Created: 2018-09-24T14:42:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-09-24T15:56:22.000Z (over 7 years ago)
- Last Synced: 2023-08-06T00:35:03.224Z (over 2 years ago)
- Topics: go, golang, string, string-manipulation, strings
- Language: Go
- Size: 3.91 KB
- Stars: 23
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/mamal72/stringish)
[](https://goreportcard.com/report/github.com/mamal72/stringish)
[](https://godoc.org/github.com/mamal72/stringish)
[](https://github.com/mamal72/stringish/blob/master/LICENSE)
# stringish
A set of chain-able string helpers to reduce the pain of manipulating strings.
## Installation
```bash
go get github.com/mamal72/stringish
# or use dep, vgo, glide or anything else
```
## Usage
### Implemented Methods
- `ReplaceN`
- `ReplaceAll`
- `ToLower`
- `ToUpper`
- `TrimPrefix`
- `TrimSuffix`
- `TrimSpaces`
- `TrimPrefixSpaces`
- `TrimSuffixSpaces`
- `HasPrefix`
- `HasSuffix`
- `Equals`
- `IsEmpty`
- `IsBlank`
- `Contains`
- `Len`
- `Index`
- `LastIndex`
- `Map`
- `Filter`
- `GetString`
### Example
```go
package main
import (
"log"
"github.com/mamal72/stringish"
)
func main() {
str := stringish.New(" hello there ")
str.TrimSpaces().Map(func(char string) string {
return strings.ToUpper(char)
})
log.Println(str.GetString()) // "HELLO THERE"
log.Println(str.Replace("HELLO", "bye").Contains("bye")) // true
log.Println(str.GetString()) // "bye THERE"
}
```
## Ideas || Issues
Just create an issue and describe it. I'll check it ASAP!
## Contribution
You can fork the repository, improve or fix some part of it and then send the pull requests back (with some tests ofc) if you want to see them here. I really appreciate that. ❤️