On Nov 29, 2003, at 11:35 AM, James Edward Gray II wrote:
On Nov 29, 2003, at 1:15 PM, Dan Anderson wrote:

I have a regular expression that looks like:

$foo =~ s[class.*?=.*?'.*?'][]sgi;

We're just looking for spaces with most of those .*?s, right? Why don't we say that. And between quotes we're looking for non-quote characters, right?

s/class\s*=\s*'[^']*'//sgi

greedy RegEx's are a good thing, except when they are TOO greedy!

Your RegEx is very Strong, but it is
short by a leading \s*

        my $foo = q{<table class='foo'><tr class='baz'><td class='bar'>};
        
        print "First foo: $foo\n";
        
        $foo =~ s/\s*class\s*=\s*'[^']*'//sgi;
        print "Second foo: $foo\n";

so that one does not wind up with

<table ><tr ><td >

with your CORRECT use of the "[^']*" - the
"anything but '" match.

Folks need to remember to clear the 'white space'
between the token and the attribute list! Which
is an ugly we all do...


ciao drieux


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



Reply via email to