From: -j b- Date: 2008-05-06T07:46:26+09:00 Subject: Escaped characters from the command-line I've run into a bit of an issue that I hope you can help with. I am working on a parser that allows the user to provide a delimiter as an argument to the script. However, I can not find a way to [elegantly] handle escaped characters (such as \t and \n). A simplified example to illustrate: # Using s = ARGV.shift puts ['west', 'side', story'].join(s) $ ./parse.rb '\t' => west\tside\tstory Now, I can do something like: s = ARGV.shift sep = s =~ /^\\(.)/ when 't' "\t" when 'n' "\n" # ... else s end end $ ./parse.rb '\t' => west side story But I feel that is probably too brittle. I tried Shellwords, but that didnt seem to help (although I could have been using it incorrectly). Any suggestions are welcome. Thanks. -- Posted via http://www.ruby-forum.com/.