Ellen
(Ellen )
September 1, 2023, 12:47pm
1
HI,
I have a text …
varText =
Line1; This is my list of users;
Line2; Department name;
Line3: Anders;
Line3: ppr;
Line3; Tim;
splitText = Split(varText, “;”)
I have used split to get the value of each line… But I want that all users names from Line3 stored on one variable…
When I write splitText(6) it gives me Anders…
how can i get all username and store in one variable…
Hi
is Line1;
Line2;
are also part of the text
@Ellen
Ellen
(Ellen )
September 1, 2023, 12:56pm
3
is a line seperator…
like line1 have differenet details…
Line 2 have different details…
Line3 will have all users name… but on different lines.
means how many users are involved then it will appear on line3
postwick
(Paul)
September 1, 2023, 12:57pm
4
Split on VbCrLf not ;
Then use RegEx to get the value of splitText(2) between : and ;
No I mean
is the word “Line1” part of the text
or you kept to explain the scenario here
based on that i can share u the expression
@Ellen
Ellen
(Ellen )
September 1, 2023, 12:59pm
6
line1 is part of text as welll…
1 Like
Ellen
(Ellen )
September 1, 2023, 1:00pm
7
im not good at Regex and that way going for split.
If thats the case here you go the steps,
use a assign activity like this
str_input_1 = Split(varText,“Line3:”)(1).ToString
then finally use a assign activity like this
str_final = String.Join(“-”,Split(str_input_1.ToString, “;”))
Cheers @Ellen
ppr
(Peter Preuss)
September 1, 2023, 1:06pm
9
maybe better to split on line break and then filtering it
postwick
(Paul)
September 1, 2023, 1:09pm
10
Just put VbCrLf instead of “;” and you have your split.
Then Google “regex find string between two characters”
And use regex101.com to test it.
Ellen
(Ellen )
September 1, 2023, 1:17pm
11
giving issue on first split
would recommend to type in again from your end rather than copying to clipboard from here
anyhow can u share the error u r getting @Ellen
postwick
(Paul)
September 1, 2023, 1:40pm
14
Don’t copy/paste from the forum. You get the wrong double quote character. Type the expression yourself.
Ellen
(Ellen )
September 1, 2023, 1:47pm
15
I wanted all usersname of Line3 but those assign is not giving me that… its output line1 and line2 with - instead on ; .
Thats not what i want… I have all the split… but I only need that when i come to line3 so in someway it loop through and add LINE3 user in one variable with a comma or ; .
like varUserName = Anders per, ppr, Tom hill, ect.
ptrobot
September 1, 2023, 1:47pm
16
To get an array of strings with regex:
arrUsers = System.Text.RegularExpressions.Regex.Matches(varText, "(?<=Line3[:;] +)[^;:]+").Select(Function(m) m.Value).ToArray
postwick
(Paul)
September 1, 2023, 1:58pm
17
Split(System.Text.RegularExpressions.Regex.Match(currentItem,"(?<=Line3)[:|;](.*)(?=;)").ToString," ")(1)
1 Like
Ellen
(Ellen )
September 1, 2023, 2:22pm
18
Check this…
test.xaml (7.3 KB)
Hi @Ellen ,
Maybe we could try with the below Approach :
Creating a Dictionary with the Mapped Names as Values.
dictLineNames = Regex.Split(strInput,"\r?\n").GroupBy(Function(x)Split(x,";")(0).Trim).ToDictionary(Function(x)x.Key,Function(y)String.Join(",",y.Select(Function(a)Split(a,";")(1))))
Here, dictLineNames
is a Dictionary of type Dictionary(Of String,String)
and strInput
is variable of type String which is the Input text data.
Implementation :
From Debug Panel :
1 Like
Hi @Ellen ,
You can able to Split the Word using either Regex Function of Split Operation to obtain the value
Hope this will be helpful !!
1 Like
Ellen
(Ellen )
September 2, 2023, 10:57pm
22
Thanks … Its giving me names… I corrected the issue.
Just one question…
When its outputting the value its give an error message at the end means write after the last name… can you tell why its giving me that ??
Error: If: Index and length must refer to a location within the string. (Parameter ‘length’)