summaryrefslogtreecommitdiff
path: root/vendor/bundle/ruby/3.4.0/gems/terminal-table-3.0.2/lib/terminal-table/util.rb
blob: a584c3d1b8802972c7ef0c4c778878e69aef1a3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
module Terminal
  class Table
    module Util
      # removes all ANSI escape sequences (e.g. color)
      def ansi_escape(line)
        line.to_s.gsub(/\x1b(\[|\(|\))[;?0-9]*[0-9A-Za-z]/, '').
          gsub(/\x1b(\[|\(|\))[;?0-9]*[0-9A-Za-z]/, '').
          gsub(/(\x03|\x1a)/, '')
      end
      module_function :ansi_escape
    end
  end
end