File: README.md

package info (click to toggle)
golang-github-acarl005-stripansi 0.0~git20180116.5a71ef0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, experimental, sid
  • size: 52 kB
  • sloc: makefile: 2
file content (30 lines) | stat: -rw-r--r-- 576 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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"
}
```