-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Thanks David and Nikolai, the \Z works as advertized :) I just have to go through the adverts now and make sure i've got them all so i don't have to ask stupid questions :) Regs, Derek David A. Black wrote: | Hi -- | | On Mon, 22 Aug 2005, Derek Wyatt wrote: | |> This one's got me stumped. |> |> I'm trying to rip out incomplete HTML tags from the end of a |> string... here's an example: |> |> Here is a string with <a\nhref=http://somewhere.com/and/then |> |> Note that there is a newline in there. So i try something simple, like: |> |> ~ str.sub(/<[^>]*?$/m, "") | | | You don't need /m here. /m has the effect of adding \n to . (the | dot). Since you're specifying [^>], that already includes \n. | | And as Nikolai mentioned, you can use \Z (or \z, the difference being | that \Z ignores a final \n) to reach the absolute end of string. | | So... try this: | | str.sub(/<[^>]*\Z/,"") | | | David | - -- Derek Wyatt - C++ / Ruby / Unix Programmer http://derekwyatt.org -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (MingW32) iD8DBQFDCaCqwwHFeC88e2IRAoxmAJsG+5AnPcK+V4/UZHe1aOjN/UQdfQCgijwj GJBHpoy/SjLFLgwdlwPvXH0= =AE5N -----END PGP SIGNATURE-----