In ruby, how do I decode c-style escape sequences? e.g. '\n' to a newline, '\t' to a tab?
Shorter, even more hacky and fairly dangerous, due to eval:
A simple example:
eval "\"#{string}\""
> a = '1\t2\n3'
> puts a
1\t2\n3
> puts eval "\"#{a}\""
1 2
3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With