> >> I have strings like the following one:
> >> my $s="The <b>L</b>ibrary<b> of <font color...";
> >> 
> >> I want to truncate the string, to become
> >> "The <b>L</b>ibrary<b> of ..."
> >> (that is remove 'unterminated' html tags - tags that open but
> >> there is no 
> >> '>' at the end, and add "..." if necessary)
> >> ...
> > 
> > In an 'unterminated' tag, you would find either the end of 
> the string 
> > or a '<', right? How about:
> > 
> > $s =~ s/<[^>]*(?:<|$)//;
> > 
> > 
> > Hope that helps,
> > 
> >  -dave
> >  
> 
> Thank you for your reply,
> 
> what about:
> 
> $s=~s/<[^>]*(?!.*?>)//;

Ok, well if that works, great :) do you understand what you're doing
there? (zero-width negative look-ahead assertion) You're looking for '<'
followed by zero or more non-'>' characters, followed by a sequence that
isn't '.*?>'.

You can remove the negative character class ( [^>]* ) if you want,
that's a bit redundant if you're going to use the negative look-ahead.

 -dave



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to