I have a datatable containing text in each row. I need to split it in to individual words where there are any spaces, hypens or special characters. If there are, remove the spacial character & print the word
For example:
Test1 Test2- tes’t te-st
Should become:
Test1
Test2
tes
t
te
st
At the moment i loop through the datatable & ‘if the row contains " ", “-”, "’"’ , pass to a strig array then loop through again, but is there a more elegant way to do it through linq or something?
Really great solutions all around, so thank you all for your suggestions. I’ve managed to implement @supermanPunch suggestion, but all the contributions worked perfectly, so thank you for your quick replies.
Can you extend your help with this please?
I have two lists that i need to iterate through and validate.
ListOne of type string contains:
Test1, Test2-, tes’t, te-st
ListTwo of type string contains:
test3, tes-t4, te’st5
My plan was to create a list variable of type string with {“ListOne”, “ListTwo”} then loop it and invoke a workflow to loop through the list using the regular expression to remove special characters. 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]
We will provide a Quick Suggestion, as this new requirement tends to be away from the original requirement, We would want to ask you to create a Separate Topic on this. However, This should be easier to implement.
So you are already splitting the string based on special characters right…That anyways is removing the special characters from string…and giving you an array of string…
Now what you want to do…is Listone of type list of string or string?
If both are lists then use
then Listone + listtwo will concatenate the lists together and create one and now to remove the special characters from each item
Thank you however, i’m unable to concatenate as these lists after being updated through the regex, the items need to be add to separate collections - depending on the orignal list source.