From: David Vallner Date: 2006-10-03T06:40:17+09:00 Subject: Re: replace a string delimited by 2 other string, regexp problem --------------enig817FD8C1571506A4A77A1FC8 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Vincent Fourmond wrote: > left =3D "/*startdel2*/" > right =3D "/*enddel2*/" > p str.gsub(/#{Regexp.quote(left)}(.*?)#{Regexp.quote(right)}/m, > "#{left}hello#{right}") >=20 The "right" could be in a positive lookahead making things probably a likkle bit faster. No lookbehinds until Ruby 1.9 / 2.0 though. p str.gsub(/#{Regexp.quote(left)}(.*?)(?=3D#{Regexp.quote(right)})/m, "#{left}hello") David Vallner --------------enig817FD8C1571506A4A77A1FC8 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (MingW32) iD8DBQFFIYdFy6MhrS8astoRAvxwAJsFcYS3yog/SDsLRa7p3UfnKf1HNwCfZ5Jm l3f8M6Ou5SQFqXFgIe1WrZY= =feCN -----END PGP SIGNATURE----- --------------enig817FD8C1571506A4A77A1FC8--