Regex for splitting a string

Hey guys.

Is there a chance that I can get the words from a string using a Regex expression?
My string contains multiple words with only 1 space between them and I want to extract them individually.

Thanks in advance.

Hi @Paul_Andrei_Turcu

Could share the Input and output structure here

Regards
Gokul

I have a read range activity from an excel file that has columns with multiple words, such as:

image

I want to build a List of Strings out of them but I only want to have one of each word

So my collection of strings should only contains one of each of those words:
For example at the end if I want to do a for each item in my collection, the output should be something like this:
printmodellen
bk
en
ok
printmodel
gebitsmodellen

Hi,

Hope the following sample helps you.

res = dt.AsEnumerable.SelectMany(Function(r) r(0).ToString.Split(" "c)).Distinct().ToArray()

Main.xaml (8.5 KB)

Regards,

You can use “,”.Join(yourString.split(" “c)) to get it as string and yourString.split(” "c) as array.

Thank you, that did the trick. I did adjust it in my case and it does work.

1 Like

Hello @Paul_Andrei_Turcu ,

You can also use the below method to achieve the same :
After read range use assign acivity

YourListVar = (From row In DT1.AsEnumerable
Select (If(row(0).ToString.Split(" “c).Length>1, row(0).ToString.Split(” "c).Last,row(0)).ToString)).ToList()

This will return you a list with the desired data in it.

Regards,
Rohith

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