[英]Capture the entire text string and convert it to asterisks
試試正則表達式/.+?(?=@)/g
var emailRegex = /.+?(?=@)/g;
var email = 'test@email.com';
var text = email.match(emailRegex)[0];
email = email.replace(emailRegex, '*'.repeat(text.length));
替換以下
/\B\w+@/g
只是
/\w+@/g
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.