in reply to String replacement with regex...

In that code, $1 won't be set, as you haven't included any capturing groups in your regexp (the only parens you have are escaped to match paren characters):
$buffer =~ s/varchar \(\d+\)/TEXT/ig if (/varchar \((\d+)\)/i and $1 > + 255);
Update: Typo corrected as per Eimi's post below. Thanks for the correction.

Replies are listed 'Best First'.
Re^2: String replacement with regex...
by Eimi Metamorphoumai (Deacon) on Aug 06, 2004 at 15:32 UTC
    You've got a small typo--should be "(\d" instead of "\(d". One other thing with the solutions--they replace all varchars on the line with texts if any of them have over 255 characters. That may not be a problem depending on how things are broken up, but it's something to notice.
    CREATE TABLE varchar (15) LastName, varchar (300) Notes
    (Apologies if my SQL is off, it's been a long time.) So here's just one more way to do it:
    $buffer =~ s/varchar\s*\( (?: \d{4,} | 2 (?: 5 [6-9] \d* | [6-9] \d+ ) | [3-9]\d{2,} )\)/TEXT/gix;