String - Remove all special escape sequences

Hi, I am asking your help because I am actually coding a parsor for Kconfig file in Linux system.

When I read a Kconfig file, I need when I browse the Array containing the file content to read each line, but without the special escape sequences, like: \n \t …etc.

How can I remove it ?

Because of that, when I perform a .starts_with?() on a string, the test fail

Don’t familiar with the Kconfig format, if you real don’t need keep the “\n” to split the config to lines for functionality correct, you can try:

files = ["foo\n", "bar\t", "baz    "]
new_files = { |e| e.gsub(/\s+/, "") }
p! new_files # => ["foo", "bar", "baz"]

Thanks a lot for your answer, I will try that now.

So I found how to do:

temp = { |line| line.gsub(/(?!\s)\[a-z]+/, "").strip }