https://github.com/acarl005/stripansi
A little Go package for removing ANSI color escape codes from strings.
https://github.com/acarl005/stripansi
ansi-colors go regex text-processing
Last synced: 5 months ago
JSON representation
A little Go package for removing ANSI color escape codes from strings.
- Host: GitHub
- URL: https://github.com/acarl005/stripansi
- Owner: acarl005
- License: mit
- Created: 2018-01-16T10:19:23.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-03-18T16:06:41.000Z (over 4 years ago)
- Last Synced: 2025-06-21T09:51:25.358Z (12 months ago)
- Topics: ansi-colors, go, regex, text-processing
- Language: Go
- Size: 1.95 KB
- Stars: 135
- Watchers: 2
- Forks: 16
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Strip ANSI
==========
This Go package removes ANSI escape codes from strings.
Ideally, we would prevent these from appearing in any text we want to process.
However, sometimes this can't be helped, and we need to be able to deal with that noise.
This will use a regexp to remove those unwanted escape codes.
## Install
```sh
$ go get -u github.com/acarl005/stripansi
```
## Usage
```go
import (
"fmt"
"github.com/acarl005/stripansi"
)
func main() {
msg := "\x1b[38;5;140m foo\x1b[0m bar"
cleanMsg := stripansi.Strip(msg)
fmt.Println(cleanMsg) // " foo bar"
}
```