How to put an escape character (not an "escaped" character) in Ruby regex?

I am trying to parse a text file with ANSI color sequences in it, for example.

\e[0;37m

How to create a regex in Ruby?

+5
source share
1 answer

Turns out this works perfectly fine:

def strip_ansi_sequence (str)
  str.gsub(/\e\[[^m]*m/, '')
end
+2
source

All Articles