--------------enig817FD8C1571506A4A77A1FC8 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Vincent Fourmond wrote: > left = "/*startdel2*/" > right = "/*enddel2*/" > p str.gsub(/#{Regexp.quote(left)}(.*?)#{Regexp.quote(right)}/m, > "#{left}hello#{right}") > 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)}(.*?)(?=#{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þÃN -----END PGP SIGNATURE----- --------------enig817FD8C1571506A4A77A1FC8--