Skip to main content
Nintex Community Menu Bar

Using a Regular Expression to Delete Characters in a Collection Variable

  • May 12, 2020
  • 9 replies
  • 19 views

Forum|alt.badge.img+2

Hi 

 

I am trying to use a regular expression to delete the characters between to two items in a collection variable. In this case  - and ;. 

 

For example, 

 

Smith, John - OrgName-SubOrg, St. Louis, MO; Cook, David - OrgName-SubOrg, Washington, DC; to be 

Smith, John; Cook, David 

 

I used  (?<=-).+(?= ; ) 

 

got this: 

 

Smith, John - ; 

 

Any help would be appreciated. 

9 replies

Forum|alt.badge.img+12
  • Scholar
  • May 12, 2020

@mrdavidcook .....what's the source of your collection value? I mean how you're getting the values  in  your collection?


Forum|alt.badge.img+2

Great question @ kunalpatel. I'm using query user profiles. 


Forum|alt.badge.img+12
  • Scholar
  • May 13, 2020

@mrdavidcook .....If you just need the name then you can use Name, FirstName, LastName attribute. Which attribute you're pulling here?


Forum|alt.badge.img+2
Thanks, @kunalpatel but first name gives me David Tom Smith Jones because its a collection variable. I am using a collection variable to collect multiple names.

and Name give me Tom Smith - Org Unit - Suborg Unit - Location. I am trying to delete all of that stuff after Tom Smith in a collection so would get David Smith; Tom Jones.

I am using First and Last Name in fields that are not collection variables.

Forum|alt.badge.img+12
  • Scholar
  • May 18, 2020

@mrdavidcook ....can you please share how you're storing the values in the collection? If it's collection then your value should be separated by ";".


Forum|alt.badge.img+2

@kunalpatel , Smith, Tom, Saint Louis MO;Bryson, Bill, Washington, DC; So we are using a ';'.


Forum|alt.badge.img+2

@kunalpatel , I got ( - )(.+)(;) as a regular expression and this deleted everything so we have Smith, Tom. The problem is that we don't get Smith, Tom, Bryson, Bill.  

 


Simon Muntz
Nintex Partner
Forum|alt.badge.img+23
  • Nintex Partner
  • May 22, 2020
I would use a foreach action and pull each index out one at a time and then grab the name with a regular expression and add it to a text variable and so on.

Forum|alt.badge.img+12
  • Scholar
  • May 22, 2020

@mrdavidcook ....I'm still trying to figure out how you're getting the values in collection variable !!!

 

I mean which attribute of the Query user profile you're pulling and I usually get a single value and not the collection if I'm using a Query user profile.