"string (12" or 1 foot or 1') into 6" MySQL varchar" into... "string (12"" or 1 foot or 1') into 6"" MySQL varchar" The string already has the leading and trailing quotes and my best effort does.. ""string (12"" or 1 foot or 1') into 6"" MySQL varchar"" I hacked my way around it with... if ((substr($t,0,1) eq '"') && (length($t) > 2)) { for ($ndx=1; $ndx < length($t)-1; $ndx++) { if (substr($t,$ndx,1) eq '"') { substr($t,$ndx,1) = '""'; $ndx++; } } } But there must be a better (^\D#) solution.