in reply to Re^2: regex needed to remove parts of SQL
in thread regex needed to remove parts of SQL

In that case,
$sql =~ s/(?<=select)\s*[^,]*?\s+as//gi ; $sql =~ s/(?<=,)\s*[^,]*?\s+as//gi ;
Looks like the problem was that (?:) is non-capturing grouping. It stills eats up the characters. What you need is lookbehind (?<=).

I also tried

$sql =~ s/(?<=select|,)\s*[^,]*?\s+as//gi ;
But the interpreter refused and said
Variable length lookbehind not implemented in regex
So, it looks like you have to have two regexes if you do not want to use $1.

Oguz

---------------------------------
life is ... $mutation = sub { $_[0] =~ s/(.)/rand()<0.1?1-$1:$1/ge };

Replies are listed 'Best First'.
Re^4: regex needed to remove parts of SQL
by jeanluca (Deacon) on Sep 12, 2007 at 12:08 UTC
    what about this
    $sql =~ s/((?<=select)|(?<=,))\s*[^,]*?\s+as//gi ;
    I couldn't have done this without your help!!

    thnx
    LuCa