// quoting style: single (') -> double (")
let text = "'I'm the cook,' he said, 'it's my job.'";
text.replace(/(^|\W)'|'(\W|$)/g, '$1"$2'));
// โฐโ1โโโฏ โฐโ2โโโฏ
// โญ๏ธ Groups that are not matched will be replaced by nothing.
// โ "I'm the cook," he said, "it's my job."
ๅ ็บ str.replace() ๆๅฐๆฏๅ match ้ฒ่กๆๅฎ็ replacer function ๆไฝ๏ผๆไปฅๅฆๆๆๅๅชๆฏ่ฆๅฐๆฏๅ match ๅๆไบๅไฝ๏ผไฝไธๅจไนไปฃๆๅพ็ๆๅญ๏ผๅณๅฏไฝฟ็จๆญคๆนๆณใๆๅๅฏไปฅๆ้็จฎๅๆณ็ถไฝๆฏ๏ผstr.match().forEach() ็ๆทๅพ๏ผไฝๅๆฒๆ str.match().forEach() ็็ผบ้ป๏ผๅ ็บๆฒๆ match ๆ๏ผstr.replace() ้ ๅคๅฐฑๆฏไธ้ฒ่กๆฟๆ่ๅทฒ๏ผไธฆไธๆ็ข็้ฏ่ชค่จๆฏใ