Hi all I have a string ‘ABCDE’
so I want the output for even index is like shown below
A
C
E
for odd index need the output as shown below
B
D
Kindly help me to get the logic for this problem
Thanks in advance
Hi all I have a string ‘ABCDE’
so I want the output for even index is like shown below
A
C
E
for odd index need the output as shown below
B
D
Kindly help me to get the logic for this problem
Thanks in advance
Try this
Evenarray = Str.Where(function(x,i) (i mod 2) =0).ToArray
oddarray = Str.Where(function(x,i) not (i mod 2) =0).ToArray
Cheers
Hi,
FYI, another approach using regex.
If you need char array, the following will work
System.Text.RegularExpressions.Regex.Replace(yourString,"(?s)(.).?","$1").ToArray()
System.Text.RegularExpressions.Regex.Replace(yourString,"(?s).(.?)","$1").ToArray()
Regards,
Drag and drop a “Matches” activity onto your UiPath workflow.In the properties panel of the “Matches” activity, set the following values:
'ABCDE'
(or the variable holding your input string)"(?<=.)(.)"
for even index or "(?<=.)(.)(?=.|$)"
for odd indexevenMatches
for even index or oddMatches
for odd index.System.Text.RegularExpressions.Match
.evenMatches
or oddMatches
depending on the desired index.Thanks!!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.