Azure AD Claim Transformation RegEx Replace Remove Character

JonBoi 0 Reputation points
2023-08-22T22:54:57.4333333+00:00

Hi All,

I am having an issue trying to get this RegEx Replace to work.

We need to remove hyphens and apostrophes from user's email address when sending a SAML Claim. This is a limitation on the vendor's part to ingest hyphens and apostrophes.

If a user has a hyphen or apostrophe in their email address, it needs to be removed when sending the claim.

Example Email Claim: ******@company.com

Expected Transform Claim / Output: BobSacamentoWilliams

Current Settings:

Transformation: RegExReplace ()

Attribute: user.mail

Regex Pattern: (?'mail'^.*?)(?i)(@.*)$

Replacement Pattern: {mail}

I am not sure where to use [^-'] in the RegEx Pattern portion to extract everything except the hyphen and apostrophe. Microsoft does not appear to be using any syntax that makes sense from other websites.

ClaimScreenShot

Microsoft Security Microsoft Entra Microsoft Entra ID
{count} votes

1 answer

Sort by: Most helpful
  1. Shweta Mathur 30,296 Reputation points Microsoft Employee Moderator
    2023-09-12T07:28:31.4766667+00:00

    Hi @JonBoi ,

    Apologies for delay in response.

    You can use below regex to

    ^(?'firstpart'[^']+)-(?'Hyphen')|(?'lastpart'[\w\.-]+@[\w\.-]+)$
    
    
    

    to remove the hyphen from the email address.

    User's image

    Hope this will help.

    Thanks,

    Shweta


    Please remember to "Accept Answer" if answer helped you.

    2 people found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.