-
-
Notifications
You must be signed in to change notification settings - Fork 117
Closed
Labels
Description
When using ANSI escapes in the text, the length of the text is being calculated including the ANSI escapes. Need to subtract that count to get the "real" length.
$s = �[38;5;47mBOVINE320�[0m Up:2.21:40:11 %FreeMem:�[92m52.1�[0m %FreeC:�[93m40.29�[0m %FreeD:�[93m20.86�[0m
[regex]$a="$([char]0x1b)\[\d+[\d;]+m"
[regex]$b="$([char]0x1b)\[0m"
$adjust = 0
$adjust+= ($a.matches($s) | measure length -sum).sum
$adjust+= ($b.matches($s) | measure length -sum).sum
#real length
$s.length - $adjust