Regex to mask the JSON Value

Comments

3 comments

  • Official comment
    Avatar
    Nathan Beltran

    Expressions that you want masked must be expressed as a capture group in the regex. Capture groups are identified with enclosed parentheses ().

    Here try this regular expression.

    primaryEmail\" : \"(.*)\"

     

    Comment actions Permalink
  • Avatar
    Nagaraju Kshathriya

    Thanks a lot @Nathan. sorry my bad actually we may get email address key in different formats. Say

    {
    "PrimaryEmail" : ""abc@domain.com"
    }
    {
    "EmailAddress" : "abc@domain.com"
    }

    {
    "emailAddress" : "abc@domain.com"
    }

    many formats. sometime camelCase and sometimes complete in capitals etc.

    My ultimate goal is to mask the value if key contains "email" or "mail"

    Thanks,
    NaGG

    0
    Comment actions Permalink
  • Avatar
    Nathan Beltran

    Try this regex. Ive included a noncapture group to match the  email fields.

    (?i:primaryemail|emailaddress)\" : \"(.*)\"

    2
    Comment actions Permalink

Please sign in to leave a comment.