yannip
November 15, 2018, 10:13am
1
Hi all,
I have the following value “1 AND 2 AND 3” but for another item it can be “1 AND 2”. I just want to stress that the amount of “AND” values can differ.
I want to perform certain actions if there is 2 times “AND” in the value.
I am trying with split but I’m not managing.
Sequence6 - testing.xaml (7.6 KB)
1 Like
indra
(Indra)
November 15, 2018, 10:25am
2
@yannip Change value type from generic to string
Sequence6 - testing.xaml (7.8 KB)
1 Like
yannip
November 15, 2018, 10:30am
3
Hi @indra , thanks for having a look.
However it does not work as I want. The output of write line var_directive2.ToString is empty and should be “2” and in the if statement i wanted “3” as output and it is giving “none”.
Pablo_Sanchez
(Pablo Sánchez Hernández)
November 15, 2018, 10:54am
4
Hi,
You have to split the string with " " value. After this you will have an array with the same positions of AND you have.
Now you have to loop this array for each string of the array, making a counter to count the AND’s
for each String, if String.Contains(“AND”) → counter+1
After that you will know when a String have 1,2,3… AND’s and you will be able to aply your logic
Hope you will understand this. Find this explanation in this .xaml _Test.xaml (10,3 KB)
Kind regards,
Pablo
2 Likes
Hi @yannip
Try this to get count of AND occurrence
Regex.Matches(str,Regex.Escape("AND")).Count.ToString
Once you get the count you can split the string according to you
Thanks,
Prankur
1 Like
yannip
November 15, 2018, 11:36am
6
Hi @Pablo_Sanchez ,
Brilliant, thanks! Got me in the right direction and found what I was looking for.
Day saver
1 Like
Pablo_Sanchez
(Pablo Sánchez Hernández)
November 15, 2018, 12:17pm
7
You are welcome @yannip
I am really happy to help you and with answers like yours, even more
Kind regards,
Pablo
system
(system)
Closed
November 18, 2018, 12:20pm
8
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.