in reply to String replacement with regex...

I think your update is comparing towards the wrong direction. No, apparently it isn't. This assertion stuff is tricky!

Anyway, here's an alternative: it replaces the text by itself if the number is small enough (effectlively doing nothing as a result), by 'TEXT' if it needs replacing.

$bar =~ s/(varchar\s*\((\d+)\))/$2 >= 256 ? 'TEXT' : $1/gei;