Skip to main content
Nintex Community Menu Bar
Solved

RegEx to add a space after a comma

  • July 26, 2022
  • 6 replies
  • 303 views
  • Translate

DavidAD
Forum|alt.badge.img+8

There is a similar question about this topic (here), but I added a question at the end of it that's never been answered - possibly because the original question has already been marked as solved.

I use @burked's solution for getting rid of the brackets and quotation marks from items in a collection, and that works fine. But it seems that NWC no longer puts a space after the comma that separates the items. So I get output like this:

Choice 1,Choice 2,Choice 3,Choice 4

 

Of course, what I want is this:

Choice 1, Choice 2, Choice 3, Choice 4

 

I know next to zilch about RegEx, so I can't figure this out. Is there an expression to add a space after each comma so that the output isn't so ugly?

Best answer by SimonMuntz

Hi ​@DavidAD,

Does looping through the collection and building the string solve the problem?
Here is an example workflow.
Key: P77PH2swUv8NNeaNd17fKi2Bt9KGumD9PwcXi25zUTFx2DQQr

View original
Did this topic help you find an answer to your question?

6 replies

Forum|alt.badge.img+8
  • Nintex Employee
  • 85 replies
  • July 26, 2022

@DavidAD, you can add a second regex action that replaces the commas (,) with a comma and a space (, ). This can be added before or after the original setup, as the one referenced in the link is just removing the brackets and quotes. I did a quick test taking the output from the first action with output of Choice 1,Choice 2,Choice 3 running the replace on , and this seemed to get the desired output. 

Output:

 

 

Translate

DavidAD
Forum|alt.badge.img+8
  • Author
  • Apprentice
  • 72 replies
  • July 26, 2022

By Jove, @burked, you've done it again! That does indeed work. Thanks very much! That's simpler than I expected.

Translate

DavidAD
Forum|alt.badge.img+8
  • Author
  • Apprentice
  • 72 replies
  • February 5, 2025

@burked: Unfortunately, this no longer works. If you add a space after the comma in the Replacement text field, Nintex Workflow removes it automatically. I was actually using a semicolon in that field, but I tried a comma too and the result was the same. Now we’re back to this after removing the brackets and quotation marks:

Option 1,Option 2,Option 3

Nintex Workflow used to add a space automatically after the default comma in a collection. That stopped working, so the above solution was useful. Now that solution is no longer working. Is there another solution for adding a space between items in a collection? I’m needing it for a new workflow I’m developing now.

Translate

SimonMuntz
Nintex Employee
Forum|alt.badge.img+22
  • Nintex Employee
  • 2473 replies
  • Answer
  • February 5, 2025

Hi ​@DavidAD,

Does looping through the collection and building the string solve the problem?
Here is an example workflow.
Key: P77PH2swUv8NNeaNd17fKi2Bt9KGumD9PwcXi25zUTFx2DQQr

Translate

DavidAD
Forum|alt.badge.img+8
  • Author
  • Apprentice
  • 72 replies
  • February 6, 2025

Hi, ​@SimonMuntz - thanks for the prompt reply. And yes - I do believe that would work! Thank you. I never would have thought of extracting the characters like that.

I developed a different workaround for my current use case that actually works better (adding each item from the collection to a table on a generated document), but I will certainly use this in the future.

Thanks again!

Translate

DavidAD
Forum|alt.badge.img+8
  • Author
  • Apprentice
  • 72 replies
  • April 15, 2025

I just thought of and applied a solution that’s much simpler, at least for adding the text to an email. I haven’t tried it in a generated document or anywhere else.

Example: my collection has been modified, using the RegEx mentioned above, to remove the brackets and quotation marks that Nintex places around each item in a collection. So I’m left with the following:

Bread,Eggs,Milk [note: no spaces after the commas]

I want to replace the commas with semicolons and add a space after each, so that I can use this text in an email. So I created a text variable in the workflow and used the Create a text string function to give the variable this value:

; 

The first semicolon is what I’m using to replace the commas; the “ ” is the HTML code for a non-breaking space. I then insert this variable into the Replacement text field of the Apply a regular expression function (see ​@burked’s visual example above). So when inserted into my email, the revised text for the collection shows as Bread; Eggs; Milk.

Translate

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings