📜  jquery 替换多个单词 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:08.004000             🧑  作者: Mango

代码示例1
// 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);
        });