开发者

How do I put an escape character (NOT "escaped" character) in a Ruby regex?

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜