How do i split and clear the blank spaces?

Hello, I have the next output through a for each that is stored in a System.Collections.Generic.List variable.

How can I delete the blank spaces from beginning and from the end of the output and also how can I split it by the last / so in the final should look like 2006, 2020 , 2019 ?

              Blank space                 J24/1368/2006     blank space
                            ,
              blank space               J22/359/2020        blank space
                            ,
                                J23/4908/2019
                            ,
                                J19/303/2018
                

Thanks

you can use .replace(" β€œ,string.empty) to remove the empty spaces and you can use .split(”/"c) to split by / into an array

I already tried those.
mystring.Replace(" β€œ,β€œstringem”)
mystring.Split(”."c).Last

getting the error message " Replace/split/trim not a member of System.Collections.Generic.List(of string)

Hi @Cookie

Can you share the screenshot of your workflow.

Also, what is the data type of your variable mystring. It appears that is not string but List(String)

And, please elaborate a little on your requirement what is the actual input and the required output. Are you iterating over this list of string and performing the operation on the each string item?

Please refer the screenshot

image

The thing is that in a for each i`m extracting some data in a variabiale ( A ) wich I wanna add to a list by add to collection and then i wanna save the output by the last data after the / (2006,2008,2009)

1

2

3
vars3

4

@Cookie

What is the issue that you are facing ?

I am getting the error message " Replace/split/trim not a member of System.Collections.Generic.List(of string)

I made a workflow that works exactly as you wanted it to with your output but i cant seem to post it because iam new. So what you want to do.

create a new list extra one,

in the for each create a assign type string with for example: strRemove = item.Replace(β€œ,” β€œβ€) (this will remove the ,)

after that create a second assign type array string, for example strTest = strRemove,Split("/"c) (this will split the string on /)

After that use the activity add to collection in the for each: in the collection input your new list, and in the item input the strtest(2).Trim (add collection makes it possible to add a string to the list, the number 2 indicates the position in the array so that we can grab the last date and trim will remove the spaces)

after that put a writeline outside the for each and put in there string.Join(β€œ,”, Newlistname)

and the output should be 2006,2019,2020

Unfortunately it is not working …

i made the exact thing in studio and it is working for me i will try to see if i can share a link
Main.xaml (9.2 KB)

Never mind, i kinda made it work.
It just needed an Assign on variable A with Var.Replace(" β€œ,β€β€œ).Split(”/"c).Last
The only thing now is that is keep writing it on a new line. like : 2006
,2020
,2019

check the main.xaml i forgot to mention you need to use a invoke method and use sort, it will sort the date

Hello @Cookie
Kindly refer this flow, You may got some idea
Forum_RemoveSpace.zip (69.3 KB)

Regards,
Gokul Jai

Thank you all very much.
I think i did it.
list

This works quite well, Thanks.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.