artmov
Scholar

Regex action to substitute for Substring

Jump to solution

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.

Labels: (1)
0 Kudos
Reply
3 Replies
Nintex_Andrea
Moderator
Moderator

Re: Regex action to substitute for Substring

Jump to solution

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.

 

Nintex_Andrea_0-1623156392569.png

 

View solution in original post

Reply
artmov
Scholar

Re: Regex action to substitute for Substring

Jump to solution
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.
0 Kudos
Reply
Nintex_Andrea
Moderator
Moderator

Re: Regex action to substitute for Substring

Jump to solution
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