Escaping # in cmd line argument
I have a simple Ruby program which takes the command line arguments and posts them to a server.
However, I want to be able to write the # (pound, hash symbol) in my arguments wit开发者_运维知识库hout ruby trying to parse it. I'm not so familiar with Ruby. I know I can pass the arg with quotes, but I would like to know if it's possible without them.
ARGV.each do |a|
s = '' + a
puts "Argument: #{s}"
end
The above doesn't work. Maybe something with gsub?
Just like this
puts "Argument: ##{s}"
#
is special in " "
only when it meets {}
. Otherwise, it shows #
.
精彩评论