--- Craig Cardimon <[EMAIL PROTECTED]> wrote:
> I need find the IMG tag in the line below,
> substituting for it the
> phrase, "IMAGE REMOVED"
>
> ***
>
> <P align=center><IMG SRC="c40736033.gif"
> ALT="LARGE-CAP VALUE INDEX FUND
> LOGO)"></P>
>
> ***
>
> Notice the unbalanced parentheses. There is no
> opening parenthesis to
> match the closing one.
>
> I have used the following pattern matching
> expressions in this attempt:
>
> /(<img\s+([^>]*)>)/gi
> /(<img([^>]*)>)/gi
> /(<img(.*?)>)/gi
>
> I get the same error message every time:
>
> Uncaught exception from user code:
> Unmatched ) in regex; marked by <-- HERE in m/<IMG
> SRC="c40736033.gif"
> ALT="LARGE-CAP VALUE INDEX FUND LOGO) <-- HERE ">/
>
> Any hints, tips, or suggestions would be
> appreciated.
>
> --
>
> Craig [ "Missed it by THATMUCH" ]
>
>
Using the example input you've given, I believe this
does what you're looking for and I didn't receive the
error you indicate. Hope this helps.
JD
#! /usr/local/bin/perl -w
use strict;
my $str1 = "<P align=center><IMG SRC=\"c40736033.gif\"
ALT=\"LARGE-CAP VALUE INDEX FUND LOGO)\"></P>";
my $str2 = $str1;
if ($str1 =~ m/<IMG(.*)>./i)
{
print "MATCHED\n[$1]\n";
#
# To substitute everything from the SRC onwards to
the first <
#
$str1 =~ s/<IMG(.*)>(.)/<IMG = IMAGE REMOVED>
$2/gi;
print "str1 [$str1]\n";
#
# or if wanting to remove the entire reference to
the IMG
#
$str2 =~ s/<IMG(.*)>(.)/IMAGE REMOVED $2/gi;
print "str2 [$str2]\n";
}
else
{ print "NO MATCH\n"; }
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs