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

Removing a last character in a variable.

Jump to solution

Hi all, I have what I hope is a fairly easy question. I'm using some regex to manipulate some data in a multiline text box. It removes some characters, puts them all in a new line and adds brackets to the left of them. And example below:

[  ] Microsoft Word

[  ]Firefox

[  ]Internet Explorer

[  ]

My problem is with that last bracket as it places that at the end. So far any pattern I used gets rid of all of the brackets. Is there a way to just trim that last one so it can look like this:

[  ] Microsoft Word

[  ]Firefox

[  ]Internet Explorer

Thank you in advance.

0 Kudos
Reply
9 Replies
Workflow Hero

Re: Removing a last character in a variable.

Jump to solution

could you provide some sample of your source data? (ideally if you could attach a text file so that it doesn't get (mis)interpreted by a browser

it looks like you have an empty trailing in input and you just prepend it with braces...

Reply
Workflow Hero

Re: Removing a last character in a variable.

Jump to solution

Of course here you go. Basically I have a form that's pulling from an XML file I created. The text comes as attached as you can it adds the ;# that seems to be a bug that SharePoint has when pulling some data. It also comes wrapped. So basically I use regex to check for that patter and replace with {Common:NewLine};[  ]

Thanks again

0 Kudos
Reply
Workflow Hero

Re: Removing a last character in a variable.

Jump to solution

Of course here you go. Basically I have a form that's pulling from an XML file I created. The text comes as attached as you can it adds the ;# that seems to be a bug that SharePoint has when pulling some data. It also comes wrapped. So basically I use regex to check for that patter and replace with {Common:NewLine};[  ]

Thanks again

0 Kudos
Reply
Workflow Hero

Re: Removing a last character in a variable.

Jump to solution

something like this might work

regex pattern

(^;#|)(?<text>.*?)(?=\|)(\|.*?;#)

replacement

(note the extra line feed. based on usage of the output you might need to replace it with a '\n' or NewLine reference)

[ ]${text}

0 Kudos
Reply
Workflow Hero

Re: Removing a last character in a variable.

Jump to solution

Thank you so much Marian that worked. Just one last thing there's another list of software. Also with ;# in front although there's no piping in any of the names so I think that's why your pattern isn't working. I changed it a bit so it does add a bracket but only one as you can see below. I'm sure it's something simple I'm missing. 

(^;#)(?<text>.*?)(?=\;#)(\.*?;#)

0 Kudos
Reply
Workflow Hero

Re: Removing a last character in a variable.

Jump to solution

try following

(;#)(?<text>.*?)(?=;#|$)

0 Kudos
Reply
Workflow Hero

Re: Removing a last character in a variable.

Jump to solution

Thank you Marian I used it and it worked but I noticed there was still a character at the end. I double checked and it looks like that software actually before any regex happens comes out ;#Firefox;#Tableau Reader;# not ;#Firefox;#Tableau Reader as I originally thought. So it looks like there's a extra ;# at the end of the software list. 

I apologize for not noticing that before. If we can get this last part this will be it. Many many thanks.

0 Kudos
Reply
Workflow Hero

Re: Removing a last character in a variable.

Jump to solution

should be easy from above, shouldn't it?

(^;#|)(?<text>.*?)(;#)
0 Kudos
Reply
Workflow Hero

Re: Removing a last character in a variable.

Jump to solution

Yes it was I've got it all working now. Thank you SO much for your help Marian. Many thanks.

Reply