$('.shijian').each(function (i){ value=$(this).attr('data');value1=value.replace(/^(.{3})(?:\d+)(.{4})$/,"$1***********$2"); $(this).html(value1); });