tamar.m
(Tamar M)
November 19, 2020, 2:25pm
1
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!!!
Sugumar8785
(Sugumar Ramachandran)
November 19, 2020, 2:27pm
2
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
Srini84
(Srinivas)
November 19, 2020, 2:44pm
3
@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
tamar.m
(Tamar M)
November 19, 2020, 2:47pm
4
But I do not know the position I want every time there is a comma that will fit into another variable
Srini84
(Srinivas)
November 19, 2020, 2:56pm
5
@tamar.m
Can you give few examples of the string you can expect
Thanks
tamar.m
(Tamar M)
November 19, 2020, 3:10pm
6
Ashkenazi - Poland, Ashkenazi - France
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
tamar.m
(Tamar M)
November 19, 2020, 3:16pm
8
Can you please send me a short exercise with this
Thank you
@tamar.m - Sure give a min…
tamar.m
(Tamar M)
November 19, 2020, 3:25pm
11
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
prasath17
(Guru)
November 19, 2020, 3:28pm
12
@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…
tamar.m
(Tamar M)
November 19, 2020, 3:30pm
13
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
prasath17
(Guru)
November 19, 2020, 3:45pm
14
@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…
tamar.m
(Tamar M)
November 19, 2020, 3:48pm
15
True just easier and more comfortable for me like that
So maybe just send me the exercise I did please
Thanks!
prasath17
(Guru)
November 19, 2020, 3:49pm
16
@tamar.m - I am more comfortable with Regex Matches personally…Give me a min I will share the output (*Not using Assign)
prasath17
(Guru)
November 19, 2020, 4:57pm
18
@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.
prasath17
(Guru)
November 19, 2020, 10:40pm
20
@tamar.m - Please refer this post for Regex learning…
1 Like
system
(system)
Closed
November 24, 2020, 11:14pm
22
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.