Find the smallest number from excel rows which need to extract with some rule

Hi

I have data in excel where some numbers will be specifically appear between $ symbol . We need to find lowest of all. N need the position of if

Here is excel data …In single column …

Dghhjjhhh 123r bhi dddj$$% road n
Ft h

Ffghkk
{)
_%fffgh

01 UiPath $. 1$. $ 45678$
02 UiPath$. 1$ $123$
03 tyuijj$. 1$ $4556$
04 hhhhhhh$.. 1$ $98$

;Value will never single digit.
Find lowest
And tell position …
Here we should get 4as output as 04 is a row of small number … better if we get all four numbers in log messages to display.there can be any no of rows …

This data is also available in text , string format or we can also write to excel in one column and each line above is a row…by generate data table… can anyone help it needs regex and linq

Tia

@S_Nitin

You can use the below in assign …requirednumber is a variable of string type and dt is where the data is present

RequiredNumber = Dt.AsEnumerable.Where(function(y) y(0).ToString.Contains("$" + Dt.AsEnumerable.Min(function(x) Cint(System.Text.RegularExpressions.Regex.Match(x(0).ToString,"\$\d+\$").Value)).ToString + "$"))(0)(0).ToString.Split(" "c).First

Cheerd

1 Like

Hi @Anil_G

  1. We have other Number also present between $ but need to only pick number higher than 1 digit and numbers can be decimal as well …

  2. Also , can i replace $ with *. ?? As in real there will be * also but for other scenarios.

  3. Req number will return the small number right

4 i also need the starting number of that small number
E.g. small number is at 4th position then i need 4
U can see 01 02 03 04 are the sequence of those numbers.

@S_Nitin

  1. I am checking the number to be present between 2 dollars so as per dataset given there is only one number
  2. Yes you can replace $ with *
  3. It would directly give you 04 only not the small number …if you need small number then use only this Dt.AsEnumerable.Min(function(x) Cint(System.Text.RegularExpressions.Regex.Match(x(0).ToString,"\$\d+\$").Value))

Cheers

Assign : conversion from string to int not valid

It will be integer right , i declare var as int.

@S_Nitin

if you need as integer then use cint around the code

I am giving output as string

cint(string) or cint(wholecode) will give integer

cheers

@S_Nitin

the regex would defer based on the input format

for this format you need to use a different one…also it would be good if you close this and create a new topic and instead of screenshot if you paste the the data it would be easy to get the regex for us

cheers

01*MNB+52357560**Z

02ghj******6*********2075600Z

These r in excel
An need to find small number and it’s seq number e.g. 2 is here