I'm trying to parse a text file that has ANSI color sequences in it, e.g.
\e[0;37m
How can I build a regex to match this in开发者_开发知识库 Ruby?
It turns out this works absolutely fine:
def strip_ansi_sequence (str)
str.gsub(/\e\[[^m]*m/, '')
end
I'm trying to parse a text file that has ANSI color sequences in it, e.g.
\e[0;37m
How can I build a regex to match this in开发者_开发知识库 Ruby?
It turns out this works absolutely fine:
def strip_ansi_sequence (str)
str.gsub(/\e\[[^m]*m/, '')
end
精彩评论