# Backslash conundrum
# Needs to escape out backslashes and other characters
# Has to save a file with all characters escaped out like
# \% \[ \] \\ etc
>> a = "hello, this is a \ backslash in a string"
>> a = a.gsub(/([^A-Za-z0-9 ])/) {|match| '\\' + match }
=> "hello\\, this is a backslash in a string"
>> afile = File.new('test1.txt', "w")
=> #<File:test1.txt>
>> afile.puts(a)
=> nil
>> afile.close
=> nilOutput of test file:
hello\, this is a backslash in a string