$sql =~ s/ \bADD\s+CONSTRAINT\s+ # lead-in to clause (\w+)\s+ # the constraint name \( # opening paren of column list / ADD CONSTRAINT $1 FOREIGN KEY ( /x;