I need a dictionary to populate a gift attribute called Matched Gift? with 'yes' if the source tracking code contains 'match'. Our source tracking codes look like this:
|E-S15-Dec. EOY $5 match 2|
|E-S16-Nov. Trump big picture $5 match resend|
|E-S16-Nov. Trump big picture $5 match test|
|E-S14-Aug BeeRpt redir match|
|E-S15-April bee acquisition lightbox match|
|E-S15-Dec. EOY $35 match|
In most cases, 'match' is at the end of the string except for the first three above. How can I do this?
What you want is a basic RegEx that searches for "match" as a word (but not a part of a larger word), and if it finds it, then "eats" the entire string and replaces it with "yes".
This seems to do that:
A closeup on that pattern:
The ^ anchors to the start of the string.
The .* part says "match zero or more of any character"
The \b is important. It means "match a 'word boundary'" which could be basically any whitespace character *or* begging or end of string/line
The $ anchors to the end of string.
P.S. I forgot Omatic RegEx's are not case insensitive by default.
Presumably, you probably want it to still work even if "match" has funny casing like: Match, mAtch, matCh, or MATCH.
This slight mod does that:
It's the same as the previous except that the "(?i)" part in the front tells it to be case >I<nsensitive or >I<gnore case.
Thanks for your response. That's not quite what I need. I want to find 'match' in one field and leave it unchanged. If 'match' is found, I want a different field (Matched Gifts?) populated with 'yes'.
You can get most of the way there with a virtual field where you copy the value from the incoming "source tracking code" to a virtual field, and have that virtual field mapped to the "Matched?" gift attribute. And then you put the dictionary on that instead of on the original "source tracking code".
The problem is-- I'm assuming you will want the "Matched?" attribute to only contain either "yes" or "no", and I'm not immediately sure of a good way to do both of those with regex. The "yes" part is pretty easy, but getting it to replace every string that *doesn't* have "match" with "no" seems tougher.
Actually, it's okay if the "Matched?" attribute remains blank if the string doesn't have "match". RE will automatically populate blank fields with "no". Would this solution work in that scenario?