From: Eric Christopherson Date: 2010-03-02T07:43:40+09:00 Subject: Re: submitting search term in quotation marks On Mon, Mar 1, 2010 at 4:10 PM, roger99999 wrote: > Silly question but I can't seem to find the answer online. I'm > submitting a search phrase in a scraper and I would like that to be in > quotation marks. Because the sterm="****" is already in quotation > marks in the code as: > > sterm = "United States" > > > , I would have to do ""******"" and that generates an error. How does > one do this? > many thanks in advance and apologies for posting such basic questions! > Roger > > The error I'm getting is the following. > > $ ruby article_parse_27feb2010.rb > article_parse_27feb2010.rb:53: syntax error, unexpected tCONSTANT, > expecting $end >  sterm = " "Double Espresso with Whipped Cream" " There are a few ways you can do it. If your string has double quotes around it, you escape the embedded double quotes with a backslash, thus "\"United States\"". Or you can enclose your string in single quotes and use the double quotes as-is (but not that this will not allow you to use #{...} or #$ or #@ inside the string). Finally, you can do as Jesus said, and use %q followed by the string enclosed in some delimiters like { }, ( ), [ ], etc.; you can actually even use single non-alphanumeric delimiters like | |, as long as they match (and aren't used inside the string itself).