symilawr
(Lawrence Symington)
November 3, 2022, 1:27pm
1
Hello,
I am trying to use a LINQ function to assign to variable. I have list that looks something like the list below:
25001\sample.json
25001\example.xlsx
25001\test.json
25002\example.xlsx
25002\sample.json
25002\test.xlsx
I want to split each item using “\” as the delimiter and keep only the first element. Using the input list above, I am trying to get the following output below:
25001
25002
Any help is appreciated.
Regards,
symilawr
Gokul001
(Gokul Balaji)
November 3, 2022, 1:30pm
2
Hi @symilawr
You can try with Regex expression ?
System.Text.RegularExpressions.Regex.Match(YourString,"\d.*(?=\\)").Tostring
Regards
Gokul
Gokul001
(Gokul Balaji)
November 3, 2022, 1:36pm
3
HI @symilawr
You can try with split expression also
Split("25001\sample.json","\")(0)
Regards
Gokul
Yoichi
(Yoichi)
November 3, 2022, 1:43pm
4
Hi,
Can you try the following expression?
resultList = yourList.Select(Function(s) s.Split("\"c).First).Distinct().ToList()
Regards,
system
(system)
Closed
November 6, 2022, 1:44pm
5
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.