Start a new topic

Dictionary to not match a specific word Part 2

I have a similar problem as Wayne had the other day. I need to build a dictionary for the Title1 Field. it reads in part:

Replacement Value 1: Mr.
Value to match on 1: Mr

Regex OFF 

Replacement Value 2: Ms.
Value to match on 2: Ms

Regex OFF 

Replacement Value 3: --Blank--
Value to match on 3: Anything else  (e.g. random characters: "A" or "M." or "CFO"  etc )

Regex ON

I tried the following RegEx expression: ^(?!(Mr|Ms|Dr|Sr|Mrs)\.$).*

But this does not work. Does anybody have a better solution?

1 Comment

I think you want it to say something like:

\b(?((Mr|Ms|Dr|Sr|Mrs)\.$)MATCHED|.*)\b

In English:

If, by this point, it finds the correct version of the text, then look for "MATCHED" in that string (which doesn't exist) and replace that part with -BLANK- (so basically do nothing).  Otherwise, replace the whole string with -BLANK-

Example 1

Input value = Mr

after step 1 value = Mr.

Regex for step 3 will do:

1)  check if "Mr." matches ((Mr|Ms|Dr|Sr|Mrs)\.$)
2)  YES so look for "MATCHED" in the value and replace that with -BLANK-
3)  That doesn't exist in the value (which is currently "Mr.") so nothing happens

Example 2

Input value = Foo

after step 1 value = Foo

Regex for step 3 will do:

  1. 1)  check if "Foo" matches ((Mr|Ms|Dr|Sr|Mrs)\.$)
  2. 2)  NO so look for .* (which is the whole string "Foo") in the value and replace that with -BLANK-
  3. 3)  That exists in the value because it IS the value so it all gets replaced by -BLANK-

That's how I understand it at least...

Login or Signup to post a comment