I am trying to retrieve the domain of my site users in order to assign them specific organisation based privileges.
If their email address is email@example.com, I want to extract example. If it’s email@ex.ample.com I want to extract ex.ample
The regex I have is (?<=@)[^.].[^.](?=.)
But I’m struggling to integrate this into the code. My code as follows:
$w.onReady(async function () {
let userEmail = await memberData.loginEmail;
retrieveTeamFromEmail(userEmail);
$w('#userAccountSetupIntroText').text = ("Let's set up your account. We have your company as " +
userEmail + ".\n\nTell us a little more about yourself.");
})
function retrieveTeamFromEmail(userEmail) {
return userEmail
.replace(?<=@)[^.]*.[^.]*(?=\.);
}
I’m getting an error at .replace:
What am I doing wrong?