在控制台中更改特定字母的颜色 [英] Change the color of specific letter in console
问题描述
我正在使用几个strcat
形成一个特定的字符串,并将其显示在控制台中.该字符串包含以下字符:1
,2
,3
,4
,5
,6
,7
,8
,9
,0
,#
,*
,E
并为此目的而使用fprintf('%s')
.
I am forming an specific string using several strcat
and displaying it into console. This string contains characters such as: 1
,2
,3
,4
,5
,6
,7
,8
,9
,0
,#
,*
,E
and am using fprintf('%s')
for this purpose.
例如:
2E4137E65922#
2E4137E65922#
是该代码的可能结果.
反正我可以在输出中突出显示E
字母吗?喜欢变红吗?
Is there anyway I could make letter E
to stand out in my output? Like making it red?
推荐答案
感谢@Dev -iL提供此信息!
Thanks @Dev -iL for this information!
虽然我的其他答案中的cprinf()
似乎不适用于单个字符,但如果要使用一种颜色并且该颜色是橙色,则此技巧用于
While it seems that cprinf()
from my other answer does not work for single characters, if there is a single color that one wants to use, and that color is orange, then this trick used for warning
in cprintf
can be used:
disp(['this is [' 8 'orange]' 8 ' text'])
更多信息,请访问: http://undocumentedmatlab.com/blog /another-command-window-text-color-hack
因此,您的代码如下所示:
Thus, your code would look like:
s='2E4137E65922#';
C=strsplit(s,'E');
str=C{1};
for ii=2:size(C,2)
str=[str ['[' 8 'E]' 8 ]];
str=[str C{ii}];
end
disp(str);
这篇关于在控制台中更改特定字母的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!