I noticed that when I receive a Lazy Approval task response, the entire email thread is included in the Task Approver Comments. I would like to Remove/Strip all lines of text in the Task Approver Comments that follow my matched <keyword>.
I'm using the Regular Expression action in Nintex and my pattern code is:
[\w\s,.:]\<keyword>:.* (In the image below, I used "Lazy" as my <keyword>)
This works great for the first line, but I have about 50 more lines below this that I'd like to remove in this action.
Is there a way to add to my formula to remove all characters after my keyword?
Firstly, can I ask why you have a backslash escape "\" in front of the "L" in "Lazy"? I don't think \L is a valid escape in .NET regular expressions.
I don't have a workflow readily to hand to experiment with at the moment. Unfortunately the Nintex implementation of Regex's is not well documented, but if it supports all the .NET options, then I think what you need is something like-
It's incredibly dangerous to come up with Regex's on the fly like this (they never work first time!) but the basic idea is-
(?s) Sets the "single line match" option, so "." matches newline as well as any character
^ Anchors the pattern to the start of the line
() The first group collects up all the items you want to keep (everything up to and including "Lazy:")
.* Everything else
Then replace with just the first match group.
I heartily recommend a google search for an online Regex tester. You can save hours of laboriously editing / publishing / testing workflows when you can see the Regex being executed live in your browser.
I have been learning with Google as my mentor, so please forgive my lack of knowledge and ability to create proper syntax. I decided that the EXTRACT function is more suited to what I'm trying to accomplish then the REPLACE function. So, instead of trying to REPLACE/REMOVE all lines after my keyword, I decided to just EXTRACT the first 2 lines of the Approver Comments into a collection variable. I used ^.*\n.*\n.* in my pattern to pickup the first 2 lines and it works great.
Thanks for your input!