github.com/opentofu/opentofu@v1.7.1/internal/command/e2etest/strip_ansi.go (about) 1 // Copyright (c) The OpenTofu Authors 2 // SPDX-License-Identifier: MPL-2.0 3 // Copyright (c) 2023 HashiCorp, Inc. 4 // SPDX-License-Identifier: MPL-2.0 5 6 package e2etest 7 8 import ( 9 "regexp" 10 ) 11 12 const ansi = "[\u001B\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))" 13 14 var ansiRe = regexp.MustCompile(ansi) 15 16 func stripAnsi(str string) string { 17 return ansiRe.ReplaceAllString(str, "") 18 }