我有流动的数组对象
let old_array = {
"valone": "facebook",
"notification": "new message! @<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9eebedfbecafdefbe6fff3eef2fbb0fdf1f3" rel="noreferrer noopener nofollow">[email protected]</a> @<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b4c1c7d1c686f4d1ccd5d9c4d8d19ad7dbd9" rel="noreferrer noopener nofollow">[email protected]</a>"
}
我想将所有带有 @ 符号的用户分解到新数组中,如下所示
let new_array = {"<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b8cdcbddca89f8ddc0d9d5c8d4dd96dbd7d5" rel="noreferrer noopener nofollow">[email protected]</a>", "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="47323422357507223f262a372b226924282a" rel="noreferrer noopener nofollow">[email protected]</a>"}
知道如何做到这一点,我有用户数组拆分,我只能收到带有 @ 符号的电子邮件。
let new_array = old_array .split("@");
最佳答案
试试这个:
let old_array = {
"valone": "facebook",
"notification": "new message! @<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8df8fee8ffbccde8f5ece0fde1e8a3eee2e0" rel="noreferrer noopener nofollow">[email protected]</a> @<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a8dddbcdda9ae8cdd0c9c5d8c4cd86cbc7c5" rel="noreferrer noopener nofollow">[email protected]</a>"
}
const result = old_array.notification.match(/(?<=@)(\w*@\w*.\w*)/g);
console.log(result);
关于javascript - 通过 @ 符号按字符串拆分数组对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57097331/