I have validation which removes special characters. When i pass ListOne through this it adds each item to a new collection (ListOneFinal). I’d like to do the same for ListTwo, but i don’t want to repeat my code.
My plan was to create a list variable of type string with {“ListOne”, “ListTwo”} then, using a switch, invoke a workflow to loop through the list using the regular expression to remove special characters & add to a new (final) collection, ListOneFinal list (of String). I cannot seem to do that as it loops the string ‘ListOne’ and productes L, i, s, t, O, n, e. I cannot seem to create a List (of string) to loop {ListOne, ListTwo} as i receive an error that it cant assign from generic list [system string] to generic list [system string]
There was a suggestion to add both Lists to a List of Lists however, in my Watch window i can see Type List<List> Value= List<List> (2){null, null}
Is there another way I should approach this please?
Sorry i’m a bit confused as i need to feed in two separate lists & recieve two separate lists as output as the results go in to two separate collections. I can’t join or concatinate them. I can see the confusion though as the test data I provided is very simalar in the separate lists
If
ListOne (of string) contains:
Amy1, Beth2-, C’hris, Da-vid
The final result going in to ListOneFinal should be: Amy, Beth, Chris, Da, vid
Thank you, that makes sense. The only thing is that there should be a new list item created when the special character is removed. Is it possible to include this in the assign?
When i use ListOne.Select(function(x) Regex.Replace(x,“[^A-Za-z]”,“”)).ToList is modifies my original list from Amy, Beth, Chris, Da, vid TO: Amy, Beth, Chris, David rather than Amy, Beth, Chris, Da, vid
For ListTwo.Select(function(x) Regex.Replace(x,“[^A-Za-z]”,“”)).ToList
It modifies it from test3, tes-t4, te’st5 to test, test, test rather than test, tes, t, te, st
Ideally where a special charaver is found it’d create a new list item in each list
If i modify your Regex to ListOne.Select(function(x) Regex.Replace(x,“[^A-Za-z]”," ") to create a space in place of the special character, I can loop through each list item & split where there is a space however i’d again need to pass both lists through a loop to do this twice. Is there a better way to approach?
Thank you Peter though, where a special charaver is found witin the list, it needs to split & create a new list item in each list. Is there a way that this can be achieved?
this requirement differs from original requirement desciption. So clear complete requirements at the begin (best with output sample) helps to speed up the solution findings
@ppr Can you tell me what variable type arrAllCleansed was in your example above please?
I have tried List , String , List<List> but to no avail. I’m just looking to improve my learning, thank you.