One variable and cut into several variables by comma

When I have a long string I want to cut it every time after a comma, put into a variable
I do not know what the length and how much sub-string I will have (how many times a comma)
For example:
The sentence is:
day, one, I went
I want it to be:
var1 = day
var2 = one
var3 = I went

I want to do it by REGEX
Thank you!!!

Hi @tamar.m

Try using Split,

YourText.Split(","c) - this will return a array of string. You can use them with the index.

As you say you might not know how many substring you will get, you can check the count of the array too.

1 Like

@tamar.m

You can use as below

Save the text in a variable eg: SampleString

Now use Assign activity
var1 = SampleString.Split(",“c)(0)
var2 = SampleString.Split(”,“c)(1)
var3 = SampleString.Split(”,"c)(2)

OR

Save the text in a variable eg: SampleString
Declare a temp variable as Stringsplit which Variable type is String

Use assign as
Stringsplit = SampleString.Split(","c)

Now
var1 = Stringsplit(0)
var2 = Stringsplit(1)
var3 = Stringsplit(2)

Hope this helps you

Thanks

But I do not know the position I want every time there is a comma that will fit into another variable

@tamar.m

Can you give few examples of the string you can expect

Thanks

  1. Ashkenazi - Poland, Ashkenazi - France
  2. North Africa - Algeria, North Africa - Morocco

In both sentences there is a comma I want it to be like this:
1.1.Ashkenazi - Poland
2.1.Ashkenazi - France

1.2 North Africa - Algiers
2.2 North Africa - Morocco
I do not know how many commas there will be in each sentence
I want to later put these values into a system.
Thanks

Can you please send me a short exercise with this
Thank you

@tamar.m - Sure give a min…

You can send me the exercise itself and not a picture
You can do the REGEX with ASSING and not with the act of REGULAR EXPRESSION
Thanks

@tamar.m - I can…But with the images I gave already , can you try to build it??

So that you can practice right??

Please try it and show the error/problem you are facing, i will take it from there…

I can do as in the picture but I prefer to have it as a small sequence of what I have created
If you can send me it would be great
And can you do with ASSIGN?
Thanks

@tamar.m - To be honest, I have never tried Regex in assign activity.

May I know, why are you asking for assign activity ? Regex matches does the same…

True just easier and more comfortable for me like that
So maybe just send me the exercise I did please
Thanks!

@tamar.m - I am more comfortable with Regex Matches personally…Give me a min I will share the output (*Not using Assign)

OK thanks

@tamar.m - Sorry for the delay. Got stuck with some office work…

Here is the xaml(Updated) : Main.xaml (7.8 KB)

Please mark as solution, if it solves your query.

Thank u!!!

1 Like

@tamar.m - Please refer this post for Regex learning…

1 Like

thank u

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