Split the data current data

Exist text : 00:00:00 15787 Online

What I want : 15787

image

HI @Manju_Reddy_Kanughula

Checkout this expression and use this inside the for each row in datatable

System.Text.RegularExpressions.Regex.Match(CurrentRow(1).Tostring.Trim."(?<=\d{2}:\d{2}:\d{2})\d+").Tostring

Regards
Sudharsan

Hi @Manju_Reddy_Kanughula

How about this Regex expression?

System.Text.RegularExpressions.Regex.Match(CurrentRow(1).Tostring.Trim."\d+(?=Online|Offline)").Tostring

image

Regards
Gokul

Another way to achieve using the Regex expressions @Manju_Reddy_Kanughula

System.Text.RegularExpressions.Regex.Match(CurrentRow(1).Tostring.Trim."(?<=\d{2}:\d{2}:\d{2}\s)\d+").Tostring

image

Regards
Gokul

Hey

another aproach if you want the same pattern in all the rows,

dtInput.AsEnumerable.Select(Function(x) Regex.Match(x("Column").ToString, "\d+(?=Online|Offline)")).Where(Function(a) a.Success).Select(Function(k) k.Value).ToList()

Regards

I have negative values, i need those values too.

“00:00:00 -72623 Offline”

How about this expression? @Manju_Reddy_Kanughula

System.Text.RegularExpressions.Regex.Match(CurrentRow(1).Tostring.Trim."\d+(?=Online|Offline)|-\d+(?=Online|Offline)").Tostring

image

System.Text.RegularExpressions.Regex.Match(CurrentRow(1).Tostring.Trim."(?<=\d{2}:\d{2}:\d{2}\s)\d+|(?<=\d{2}:\d{2}:\d{2}\s)-\d+").Tostring

image

Regards
Gokul

You can try this @Manju_Reddy_Kanughula

System.Text.RegularExpressions.Regex.Match(CurrentRow(1).Tostring.Trim."(?<=\d{2}:\d{2}:\d{2}).*(?=\sOffline|\sOnline)|(?<=\d{2}:\d{2}:\d{2}\s).*(?=\sOffline|\sOnline)").Tostring.Trim

Regards
Sudharsan

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.