Solved

Regex action to substitute for Substring

  • 8 June 2021
  • 3 replies
  • 105 views

Badge +5

I need to parse a string in a workflow.  Basically, I need to get a substring out of it by position, just like Substring function does.  Since I cannot use functions in the workflow, I am trying to use the Regular Expression action instead.  Still, I have been struggling to get the correct pattern.  Can someone recommend a regex pattern that would substitute a substring function?  Say to get a part of string from 5th to the 10th position.

Thank you.

icon

Best answer by Nintex_Andrea 8 June 2021, 14:45

View original

3 replies

Userlevel 2
Badge +5

I was able to get this expression to work in my test workflow: (?<=^.{4}).{5} Where 4 represents the starting position and 5 represents the number of characters you want to extract. Keep in mind that the character index starts at 0 not 1.


 



 

Badge +5
Hi @Nintex_Andrea,

This is incredible. I spent so much time trying to get the correct pattern, and still was not getting anywhere. It is strange that Nintex is not taking literal integers in the expression, but only variables. I would have not guessed it if not for your screenshot.
Thank you so much for the help.
Userlevel 2
Badge +5
I was able to get it to work with both literal integers and variables. I ended up creating a component workflow to call from other workflows... like a function. So I ended up using the start variables in the expression. But it should work either way.

Reply