cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

Unexpected behaviour of replace() function

Jump to solution

Dear all,

I'm using Nintex Forms 2013 and the replace() function gives me some troubles.


I get a string like this, from an people picker field:


XXXXXX|YYYYYY|StringOfInterest

Where the length of the "XXXXXX" and "YYYYYY" substrings (at least to my knowledge) are not known. I want to extract the substring "StringOfInterest", i.e. replacing "XXXXXX|YYYYYY|" with "". I am using the expression  (.*\|){2} , which does exactly what i want to, when i enter it on https://regexr.com/ , but if i use it in the replace function in a calculated field like so:

replace(PeoplePicker,"(.*\|){2}","")

i always get an empty string (yes, PeoplePicker has a value in it). 

If i use something like this:

replace(PeoplePicker,"(.*\|){2}","k")

i get the output:

k

,which implies that the expression matches, but disregards the umatched part of the source String. This sounds to me like a thing that the replace function shouldn't do, or did i misunderstand the replace function?
It would be nice if someone could shine a light on my lack of knowledge.

Labels: (2)
0 Kudos
Reply
2 Replies
Workflow Hero

Re: Unexpected behaviour of replace() function

Jump to solution

you have to escape backslash itself as well.

try

replace(PeoplePicker,"(.*\\\\|){2}","")
0 Kudos
Reply
Workflow Hero

Re: Unexpected behaviour of replace() function

Jump to solution

hi marian,

Thanks for the hint.

replace(PeoplePicker, "(.*\\|){2}" , "")

This did the job for me, though it is beyond me, why the escaped sequence "\|" has to be escaped again...

Reply