$_ = "INSERT INTO TABLENAME VALUES ('bunch o'f text','another text','anot'cool'her text')";
s/\G
(?<=')
((?:
(?> [^\\']* )
| \\.
| '(?![,)])
)*)
('[,)])
/fix("$1").$2/egx;
print;
sub fix {
$_[0]=~s~(?##
INSERT INTO TABLENAME VALUES ('bunch o',f text','another text')
####
INSERT INTO TABLENAME VALUES ('bunch o')f text','another text')