Regular Expressions in Office 365

  • 22 April 2015
  • 1 reply

In the April '15 update to Nintex Workflow for Office 365, the Regular Expression was made available.  As a techie, I was super excited about this as I tend to use regular expressions a lot, whether I was building on-premise workflows or I was writing code.

Regular Expression Action.png

The Regular Expression action brings you 4 pieces of important functionality. So in effect, it's 4 actions in 1.  Here are the 4 operations.





Different business processes will require different regular expression operations.


When you have string of text, and there is a part or maybe multiple parts that you want to replace with something else, this is the perfect way to do it.  Once great example, is if you have some email body template that you store in a List or Library that your workflow will be using to send out an email.  The template can have some tokens in it, that you can then use the Regular Expression action, to dynamically replaces those tokens at runtime, with real values.

We'll start off with some hardcoded text to show you how to replace a substring with something else.  In the example below, our initial text is just that alphabet and we want to replace "lmn" with "###".


Some of the things to note.  The first parameters, "String", can be typed in text like above, but that is very rare that you'll do this.  Instead, it'll contact a workflow variable or item property, or a combination.  The next parameter is the "String operation", which is where you check the "Replace" radio button.  The next is where Regular Expressions are really powerful.  You type in your regular expression here.  In the example above, we are simply looking to replace "lmn".  But you could have something like this [l-n]+, which would replace any combination of 'l', 'm', and 'n' with "###".

The output of the "Replace" operation is a text variable.  In a lot of cases, your first String parameters and your Output parameter will be the same variable.

Here is another, more complex example of using the Replace operation.

We start off with an email body template that looks like this :

Dear #!name!#,

We would like to cordially invite you to the #!event!#, and look forward to your presence there.

Please reply to this email by #!replydate!#, letting us know if you will be able to make it.

Thank you for your time,

The Hat and Umbrella Corp

I've highlighted 3 tokens in the template that I want my workflow to replace.

Firstly, this template is in a document library, so I need to use a Web Request action to perform a GET and store that in a variable.  If you want to see how that works, it's in the workflow attached to this post.

Finally, since I have 3 unique tokens, I'll need 3 Regular Expression actions to replace each one.  This is what they look like :




The result is an email body that I can then use to send to the person who submitted the form. Or, maybe you have a workflow that iterates through a list of contacts and sends out this email.

Here is a short version of the email body (I'm logged in as someone called SPSiteAdmin):

Dear SPSiteAdmin,

We would like to cordially invite you to the Nintex Roadshow, and look forward to your presence there.

Check Match

The Match operation lets your workflow look at some text, to see if it matches a particular expression or notation.

A good example is if someone has submitted a form that has an email address and your workflow needs to work off of that, to send a notification to the address.  You may want to build some logic/validation into your workflow to make sure that what we have is in fact a valid email address structure.  Within reason.  Here is an example of a Regular Expression to looks for a specific type of email, and it must come from a .com, .edu, .org, or .gov email address.  Granted, it doesn't support a lot of email addresses, but this is just an example.



The output of this operation is a Boolean variable.  You can then use that in a Conditional Branch or Run If action to see if the data matched or not.


This is by far my most use operation. This operation lets you take a bunch of text, and split it based on some delimiter. Sometimes, you'll have some text that is delimited by a semi-color or event more popular, comma delimited, like CSV (Comma Separated Values).  Now you can easily split that data.

Why would you want to do this? Because most of the time, it's a bunch of data that by itself, you can't do a lot with.  But if you split that data, you can then iterate through each result and do something with it.

Lets say you have a text string that is made up of a number of email addresses, separated by a semi-colon and you want to go through each email address and send each one an email, but slightly customized for each person.  You can do that with just the one text string.  You need to split it and then email each address individually.


Although the pattern in the above example is just a semi-colon, it can be as complex as you need it to be.

eg. your text may be semi-colon or comma delimited and in that case, your expression could be ;|,

The output of this operation is a Nintex Workflow Dictionary variable.  I have an example in the workflow attached to this post on how to parse the dictionary, but suffice it to say, you get the number of items in the dictionary, then you go through a Loop and pull out the values at the particular index and store it in a text variable.  There will be another post about doing this shortly.


Yet another operation that is very powerful, but it really shines when you have some structured text that you can build a regular expression to pull out values.


In the example above, we have a bunch of text and we want to pull out any combination of numbers 4 to 6.  This is probably not an awesome example of this operation, but it is the simplest.

The output of this operation is a Nintex Workflow Dictionary variable.  Why?  Because in most cases, your extracting data and you will get multiple values back. That's why the result isn't a text variable but instead, a dictionary variable.


In the above example, we have an AD distinguished name and we want to pull out the Common Name.  In this case, it'll be "Wombat".

The regular expression some something like is :


You're probably wondering that that mess is?  In short, give me all the text that is between the "CN=" and the ",".  How would you come up with something like that?  I recommend you look online for some regular expression cheat sheets and play around with them.  There's a tonne of information on the web around Regular Expressions.  The one I like is this one : RegExr


Download the attached workflow and try it out.  The first action is a Web request action, which you'll need to either modify or remove, since it uses credentials.

If you have any questions, please post on the comments.

1 reply

Another excellent addition!