cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Nintex Newbie

Replace a String of Characters between a Start and End String

Jump to solution

Hello!

 

I'm looking to replace a random string back to blank for use in a repeating section.

For example I need this..

<SubTaskComments type="System.String">Some Comments</SubTaskComments>
<SubTaskComments type="System.String">Some more Comments</SubTaskComments>
<SubTaskComments type="System.String">Even more Comments</SubTaskComments>

 

To Be.. 

<SubTaskComments type="System.String"></SubTaskComments>
<SubTaskComments type="System.String"></SubTaskComments>
<SubTaskComments type="System.String"></SubTaskComments>

 

I'm doing this to reset a repeating section field back to a starting point without removing all of the data from the repeating section. I.E just the one column containing the comments.

 

Thanks for any help.

 

T.

Labels: (1)
0 Kudos
Reply
5 Replies
Highlighted
Nintex Newbie

Re: Replace a String of Characters between a Start and End String

Jump to solution

@Stonehage easiest way to do that would be to use the regular expression action. Use this pattern 

(?<=\>).*(?=\<)

to find the data between the two xml patterns and for each one it will extract it. You will have to do this as a loop to get all the comments out, but that shouldn't be difficult. You would use the replace and simply replace the text with nothing and it should return your original string empty. 

image.png

You can use the run now button to test the logic and see if your pattern returns what you want it to look like. Simply store than back into the variable then rebuild the XML as needed.

0 Kudos
Reply
Highlighted
Nintex Newbie

Re: Replace a String of Characters between a Start and End String

Jump to solution

Thanks for that. I'm still struggling though. I think I needed to give more info..

 

This is my full xml example from one of my tasks...

 

<?xml version="1.0" encoding="utf-8"?><RepeaterData><Version /><Items><Item><SubTaskName type="System.String">Sub Task 1</SubTaskName><SubTaskOutcome type="System.String">Complete - No Issue</SubTaskOutcome><SubTaskComments type="System.String">Ok</SubTaskComments></Item><Item><SubTaskName type="System.String">Sub Task 2</SubTaskName><SubTaskOutcome type="System.String">Complete - No Issue</SubTaskOutcome><SubTaskComments type="System.String">Ok</SubTaskComments></Item><Item><SubTaskName type="System.String">Sub Task 3</SubTaskName><SubTaskOutcome type="System.String">Complete - No Issue</SubTaskOutcome><SubTaskComments type="System.String">Ok</SubTaskComments></Item><Item><SubTaskName type="System.String">Sub Task 4</SubTaskName><SubTaskOutcome type="System.String">Complete - Issue</SubTaskOutcome><SubTaskComments type="System.String">Ticket raised 2015464.</SubTaskComments></Item></Items></RepeaterData>

 

Which looks like this on my form.

 

SubTask1.JPG

On completion of the task, a workflow archives the task to another list and I'm then trying to reset the answers but preserve the Sub Task names. I.E Back to...

 

SubTask2.JPG

The Task outcome was simple. I just used replace. The comments are random hence my original question.

If I use the expression you gave it works on just the original sample but wipes the full xml.

 

T.

0 Kudos
Reply
Highlighted
Nintex Newbie

Re: Replace a String of Characters between a Start and End String

Jump to solution

@Stonehage Any chance we can schedule a call to screenshare and walk through what you're doing? Here is a link to schedule some time with me - https://calendly.com/eric-harris. 

 

I think there may be a few easy processes to try here that may not need to wipe or reset that XML. 

0 Kudos
Reply
Highlighted
Nintex Employee
Nintex Employee

Re: Replace a String of Characters between a Start and End String

Jump to solution
Hi,

You could always use the update xml action to replace the specific nodes contents with blank.

View solution in original post

0 Kudos
Reply
Highlighted
Nintex Newbie

Re: Replace a String of Characters between a Start and End String

Jump to solution

So it was quite simple in the end...

 

UpdateXML.JPG

 

So no looping. Just a read and then an update.

 

Thanks for the help.

 

T.

0 Kudos
Reply