Last updated on December 1st, 2016 at 10:00 am

I was writing a workflow in SharePoint Designer to take actions based on the values of a multiple selection choice field.  Let’s say your choice field has the following choices:

  • A
  • B
  • AB

Any or all of the above choices can be selected.  I used “contains” to check for the existance of particular choice selections … if field contains “A” do this, if field contains “B” do this, etc.  However, what happens when “AB” is selected?  Workflow for “A” and “B” would fire, because “AB” contains both.  Why not use “equals” instead of “contains”?  That would be very lengthy, because the result could “equal” … “A”, “B”, “AB”, “A, B”, “A, AB”, etc.

RegEx to the rescue!  Instead of using “contains” for “A” and “B”, use “matches regular expression” and use the word break expression \b.  For the above example, we can use \bA\b to match just “A” and \bB\b to match just “B”.  We can still use “contains” for “AB”.