~poldi1405/go-ansi

ref: 76d320c6afe7577b81dc9a9196484bbcad5057a9 go-ansi/strip.go -rw-r--r-- 304 bytes
76d320c6 — Moritz Poldrack added function to remove all ANSI-Codes from a string 1 year, 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
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])*)`)