From: Eero Saynatkari Date: 2006-10-03T16:27:49+09:00 Subject: Re: shell, ruby and regexp --xUq7mlTLx96rFlBf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2006.10.03 16:05, Une b?vue wrote: > Paul Lutus wrote: >=20 > >=20 > > What's wrong with the original string enclosed in quotes? > >=20 > > Instead of: > >=20 > > ruby test_args.rb /to.*/ > >=20 > > Type this instead: > >=20 > > ruby test_args.rb "/to.*/" >=20 > ok i've done THE MISTAKE to rememeber zsh as a priority over ruby ))) >=20 > my answer to "What's wrong with the original string enclosed in quotes?" >=20 > that didn't work, my script sees it as a string and even if (for this > arg and if enclosed with //) : Everything you get in ARGV is a String. You cannot create Ruby objects outside Ruby. > this_arg=3DRegexp.new(this_arg) >=20 > then if this arg =3D "/to.*/" >=20 > i get : >=20 > puts this_arg.source # (after Regexp.new) >=20 > # =3D> /to.*/ INSTEAD OF to.* You have a few choices. You can pass in '/to.*/' and strip off the /'s, you can #eval it or you could pass in 'to.*' instead and then interpolate= =20 or Regexp.new it. --xUq7mlTLx96rFlBf Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (FreeBSD) iD8DBQFFIhB97Nh7RM4TrhIRAllBAJ4/yPa4ozg9wnU7Y6wwn+3P7ASjgQCcChig Aen8bQW/5AyUF1Be1s8EeAg= =wsHh -----END PGP SIGNATURE----- --xUq7mlTLx96rFlBf--