in reply to keeping one pattern but removing all else from a string

Here's another (less appealing ... err.. worse) solution using raw regular expressions:

Try this...
my $font_tag_match = m{ # Tags in pairs like <foo>content</foo> \< \s* (<font[a-z:\=]>+) [ \s*<[a-z:]>* \s* = \s* [ ' <[^']>* ' | " <[^"]>* " ] ]* \s* \> [ <[^<>]>* | <xml> ]* \< \s* / \s* font \s* \> }x; # remove all text that is not between a pair of <font> tags.. $input_data =~ s/^$font_tag_match//mg;
Unfortunately I had to make up the code without any bit of testing as I don't have the means to do so on this particular PC (Have to reboot my Win2000 OS as the MS-DOS command prompt wouldn't work for some reason ;/)

_____________________
# Under Construction

Replies are listed 'Best First'.
Re: Re: keeping one pattern but removing all else from a string
by Anonymous Monk on Jul 13, 2002 at 04:04 UTC
    Thanks. But I need to keep the content ,without html outside start and end tags. The solution above will preserve everything between font tags but remove the content outside completely. The way CODE tag implemented here is very similar to what I want. It removes all html outside code but preserves it inside and makes it in different font.