SharePoint Workflow: RegEx Similar Choices

By James|04/09/2013|,

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".

Copyright 2011 - 2024 The Lazy IT Admin | All Rights Reserved
menu-circlecross-circle linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram