How to make this javascript code working in google sheet app scripts

Viewed 28

i want extract phone number using this code in Google sheet App Script. please some body help me

    const string = 'Personal Kontak · Nama. Linda · Jabatan. Marketing · Telepon. 021-22597930 · HP. +62 8119108808 / +62 8118824383 · Email. linda.dulseokindonesia@gmail.com.';
let phone_numbers = [];
const regexp = new RegExp("\\+?\\(?\\d*\\)? ?\\(?\\d+\\)?\\d*([\\s./-]?\\d{2,})+","g");
phone_numbers = [...string.matchAll(regexp)];
for (const match of phone_numbers) {
  document.write(match[0]);
  document.write(';');
}
console.log(phone_numbers);
// expected output: Array ["+1 671-765-0091", "-0091"]

Thank you

0 Answers
Related