Skip to content

A little Go package for removing ANSI color escape codes from strings.

License

Notifications You must be signed in to change notification settings

acarl005/stripansi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

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

$ go get -u github.com/acarl005/stripansi

Usage

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"
}

About

A little Go package for removing ANSI color escape codes from strings.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages