I am doing a regex match that returns a IEnumarable , if i string join the result is like this:
“894215763”, How do i order this so i can loop this IEnumarable in order like this:
“123456789”
Hi @Jay_Chacko - Could you please let us know, your Regex text and Regex pattern? In the meanwhile, i will take a look on how to sort IEn.
@Jay_Chacko - Here you go…
StrArray = IEnRegex.Select(Function (x) x.toString).toArray
StrArray is of Variable type String Array.
Then Use InvokeMethod.
Note: This method works, but I am trying to do it one step.
Hi @Jay_Chacko
to do all the all the operation in one-step u can try this in a writeline activitiy to get the output
String.Join(“”,matches_var.OrderBy(Function (e) e).ToArray)
Where matches_var is output of matches activitiy
Regards
NIVED N
Happy Automation
instead of x can u try with x.value?
I am yet to try to try that
it kinda works , but getting the return like this , “Sorted: 013689”, original was :“8,9,10,6,3”. It split 10 to 0 and 1, my regex pattern is simple digit “(\d)”
@Jay_Chacko - Sorry I didn’t get you. I tested the above sort against my matches and it works perfectly…
Before sort(With String.Join)
After sort
Could you please share your input Regex text?
Raw text start
i Global - PRV
Aime/$33495PRv-RecurrlngoUtpauent-oz/01/2 A
[:- i PRV-Facesheet
A a SPR-Therap‘,’ Reccrds-Admit Docs
@ PT42159765 02/01/2021 03:00:00 PM (8)
@ PT42159792 02/03/2021 02:00:00 PM (8)
@ PT42159603 02/05/2021 02:00:00 PM (8)
@ PT42159660 02/08/2021 03:00:00 PM (8)
@ PT42159673 02/12/2021 02:00:00 PM (8)
@ PT42159924 02/10/2021 12:15:00 PM (8)
@ PT45263657 02/16/2021 02:00:00 PM (8)
@ PT45263890 02/18/‘2021 03:00:00 PM (8)
@ PT45263891 02/23/2021 03:00:00 PM (8)
@ PT45263893 02/25/2021 03:00:00 PM (8)
@ 5942160079 02/01/2021 02:00:00 PM (8)
lg 5942160090 02/051’2021 03:00:00 PM (8)
@ 5942160104 02/12/2021 03:00:00 PM (8)
@ 5942160109 02/03/2021 02:00:00 PM (8)
lg 5945573038 02/16I2021 03:00:00 PM (8)
lg 5945573049 02/18I2021 02:00:00 PM (8)
lg 5945573061 02/231’2021 02:00:00 PM (8)
lg 5945573067 02/251’2021 02:00:00 PM (8)
A a SPR-Therap‘,’ Reccrds-Rehab Rcds
lg PT42159765 02/01/2021 03:00:00 PM (9)
lg PT42159792 02/03/2021 02:00:00 PM (9)
lg PT42159303 02/05/2021 02:00:00 PM (9)
lg PT42159360 02/08/2021 03:00:00 PM (9)
lg PT42159373 02/12/2021 02:00:00 PM (13)
lg PT42159924 02/10/2021 12:15:00 PM (9)
lg PT45263857 02/16/2021 02:00:00 PM (9)
lg PT45263890 02/18/2021 03:00:00 PM (9)
lg PT45263891 02/23/2021 03:00:00 PM (9)
lg PT45263893 02/25/2021 03:00:00 PM (9)
@ 5942160079 02/01/2021 02:00:00 PM (10)
lg 5942160090 02/051’2021 03:00:00 PM (10)
lg 5942160104 02/12I2021 03:00:00 PM (16)
lg 5942160109 02/031’2021 02:00:00 PM (10)V
{I11 5LP45573038 [12/16/2021 03:00:00 PM (10)
Raw text End
Regex pattern: “(\d+)”
result: (8)(8)(8)(8)(8)(8)(8)(8)(8)(8)(8)(8)(8)(8)(8)(8)(8)(8)(9)(9)(9)(9)(13)(9)(9)(9)(9)(9)(10)(10)(16)(10)(10)
Now sort it : lowest number to highest
i replace the bracket with pipes so i can split the string on correct number
String.Join(“”,folderTreeSplit).Replace(“(”,“|”).Replace(“)”,“|”)
folderTreeSplitStringJoin.Split("|"c) = string array
Invoke sort is not sorting it , getting -: ,10,10,10,10,13,16,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9
@Jay_Chacko - Please check this regex link…We can take the groups and sort it…
I am looking at it…
Hi @prasath17
U can check this
String.Join(“”,matches_var.ToArray().OrderBy(Function(e) e.Value.ToString))
I think it will too work
please refer @Jay_Chacko
@Jay_Chacko - Here you go
XAML Image:
Regex Pattern used: “\ (\ d+\ )” - purpose added space just to show here…you can ignore
ArrItems = IEnRegex.Select(Function (x) Cint(x.tostring.Replace(“(”,“”).Replace(“)”,“”))).toArray
ArrayItems is Int32Array
Invoke Method Parameters:
My output:
thanks works like a charm
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.