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

-- 
David A. Black
dblack / wobblini.net