JSFiddle - React, Tailwind, and code Playground

by nobuts

HTML

<span class="phone">662341232354</span>

JavaScript

$(".phone").text(function(i, text) {
      text = text.replace(/(\d{2})(\d{3})(\d{3})(\d{4})/, "+$1 ($2)-$3-$4");
      return text;
    });