Answers for "jquery replace multiple words"

0

jquery replace multiple words

// jQuery search and replace space in 10 digit phone number with dots (.)
(".some-class").each(function() {
            var text = $(this).html();
  // Start search at "Phone: " then 3 digits space 3 digits space 4 digits
  // "Phone: 901 123 4567" -> "Phone: 901.123.4567"
            text = text.replace(/Phone: (\d{3}) (\d{3}) (\d{4})/, "Phone: $1.$2.$3");
            $(this).html(text);
        });
Posted by: Guest on September-02-2020

Code answers related to "jquery replace multiple words"

Code answers related to "Javascript"

Browse Popular Code Answers by Language