~mpldr/go-ansi

76d320c6afe7577b81dc9a9196484bbcad5057a9 — Moritz Poldrack 3 years ago f4db939 v1.3.0
added function to remove all ANSI-Codes from a string
1 files changed, 11 insertions(+), 0 deletions(-)

A strip.go
A strip.go => strip.go +11 -0
@@ 0,0 1,11 @@
package ansi

import "regexp"

// StripString removes all ANSI-Escape sequences from the given string and
// returns the cleaned version
func StripString(str string) string {
	return DetectionPattern.ReplaceAllString(str, "")
}

var DetectionPattern = regexp.MustCompile(`(?m)((\x1b\[[;\d]*[A-Za-z])*)`)