Hi All,
I am trying to use regex in linq query but getting errors
ExtractDataTable.AsEnumerable.Where(Function(x) (System.Text.RegularExpressions.Regex.Match(x(“List price (Quantity)”).ToString,“\d+.\d{2}\d*(?<=[1-9])|\d+.\d{2}”).Value).CopyToDataTable
My steps are first I should regex in column(“List price (Quantity)”) in Linq Query and then use the final query in the next step of If Condition
ExtractDataTable.AsEnumerable().
Where(Function(row) row.Field(Of String)(“Charges”)=sku_name AndAlso
row.Field(Of String)(“List price (Quantity)”) <> sku_listprice).Count > 0
@Anil_G any thoughts on this ?
ppr
(Peter Preuss)
December 19, 2024, 3:58pm
2
We would suggest to do some more preparations. In general give a try at
(From d in ExtractDataTable.AsEnumerable
Let rv = System.Text.RegularExpressions(d("ColNameOrIndex").toString.Trim, "YourRegexPattern").Value
Where Here_A_Boolean_Return_From_Check_is_required
Select r=d).CopyToDataTable
Above Statement has at least the issues:
→ (Syst - Bracket
no Boolean returned from Where Check Lambda
[HowTo] LINQ (VB.Net) Learning Catalogue - Help / Something Else - UiPath Community Forum
And also:
This HowTo introduces how to use the Where operator.
Introduction
The Where operator is used for filtering. For the filtering, a condition is provided. All items matching this condition will pass the filter and will be part of the returned result.
The condition has mandatory to return a boolean outcome. In other words: The result of the condition has to be True or False.
Example
IPO
Samples
Comment
Values:
20,3,17,22,10,25,5
A collection of Numbers
Filter Condition:
x > 15
x is th…
ppr
(Peter Preuss)
December 19, 2024, 4:01pm
3
we had seen Regex.Match and mentioned the not available lambda Boolean return.
Maybe the intention was about using Regex.isMatch
[CheatSheet] - System.Text.RegularExpressions | RegEx - News / Tutorials - UiPath Community Forum
But then .Value is not needed
@ppr
Shall I not write .Value ?
What should be the correct expression for the below query?
ExtractDataTable.AsEnumerable.Where(Function(x) (System.Text.RegularExpressions.Regex.Match(x(“List price (Quantity)”).ToString,“\d+.\d{2}\d*(?<=[1-9])|\d+.\d{2}”).Value).CopyToDataTable
Anil_G
(Anil Gorthi)
December 19, 2024, 6:14pm
5
@dutta.marina
Ideally this si what you can use
ExtractDataTable.AsEnumerable.Where(Function(x) System.Text.RegularExpressions.Regex.IsMatch(x("List price (Quantity)").ToString,"\d+.\d{2}\d*(?<=[1-9])|\d+.\d{2}")).CopyToDataTable
Cheerd
1 Like
system
(system)
Closed
January 3, 2025, 3:07pm
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.