AnsweredAssumed Answered

Unexpected behaviour of replace() function

Question asked by freidavi on Jan 9, 2018
Latest reply on Jan 11, 2018 by freidavi

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.

Outcomes