Sensitive Data Policy: RegEx with Positive LookBehind

StephanBStephanB Munich, GermanyCommunity Member Qubie ✭
edited July 14 in Custom Code

Sensitive Data Policy: RegEx with Positive LookBehind

We want to set up a Custom Topic for Sensitive Data Policy. We have strings like "I like the work of Mr Smith, and my favourite employee is Mrs. Miller", and want the names to be anonymized. We are searching for addresses like Mr or Mrs. but want to be deleted only the word afterwards: "I like the work of Mr *********, and my favourite employee is Mrs. *********". We would achieve our goal with a RegEx pattern like

(?<=\b(Mr(\.?)|Mrs(\.?))([ ,:;?!)]))(((\s(\w|-|/)+)|(\w|-|/)+)\s*(\w|-|/)*)

But Qualtrics doesn't allow the positive lookbehind (?<=expr), so omitting that part, we receive "I like the work of *********, and my favourite employee is *********". Any idea how to save the addresses, but delete the personal information?

Sign In to Comment