Command line with regexp same as script but didn't work

hello !
i have to comment a link in lots html pages of a static site (with
tables everywere ) :
with my little ruby script :

while get
   gsub(/()/, '')
  print
end

it ok , but when i try try with command line :

cat  file.html | ruby -pe 'gsub(/()/, '')'

i got a error :

e:1:in `gsub': can't convert Fixnum into String (TypeError) from 
-e:1 

anybody can tell me why ??
(sorry for my bad english)

On 29/06/06, agouti agouti [email protected] wrote:

it ok , but when i try try with command line :

cat  file.html | ruby -pe 'gsub(/()/, '')'

i got a error :

Perhaps it’s because you tried to nest single quotes within single
quotes. You need to use something else instead, like double quotes or
%q (equivalent to '):

cat file.html | ruby -pe ‘gsub(/(<td.agenda./td>)/, %q())’

Paul.

On Jun 29, 2006, at 10:00 AM, agouti agouti wrote:

it ok , but when i try try with command line :
Posted via http://www.ruby-forum.com/.

I suspect it’s a quoting issue. I would try:

ruby -pe ‘gsub(/(<td.agenda./td>)/, %q{})’

Note that you also double those \ depending on your shell (e.g. \1
instead of just \1 )

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs