0

i have some sting. How do I replace a phone number with a clickable link in it?

const regex = /(?:\+|\d)[\d\-\(\) ]{9,}\d/g;
str = `It has survived not only five centuries,
      +7 (900) 000 00-00 but also the leap into electronic typesetting, remaining  
      essentially unchanged 8(900) 111-2233.`
      
      
let result = str.match(regex)

console.log(result)

I was able to find all the numbers using a regular expression, but how do I replace them with links?

qwerty
  • 193
  • 4
  • 14
  • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#switching_words_in_a_string – Rory McCrossan Oct 28 '22 at 08:05

0 Answers0