How to find a partial match from output_value and match it to value in a dt_datatable then use the partial match found to add row
output_value = "12345600"
dt_datatable = {"123456", "263456"}
Thank you in advance.
Firstly, from your example above you dont have a datatable, it looks more like a list however for this answer I will assume that you have the following string called output_value
and a datatable called dt_datatable
with a single column called partial
.
output_value = "12345600"
dt_datatable
partial
"123456"
"263456"
The below line of code sort of answers the above question, it will identify the first row as this meets the criteria inferred in your question, output_value
starts with whats in the row meaning they have a partial match.
dt_datatable.AsEnumerable.Where(Function (r) output_value.StartsWith(r.Item("partial").ToString())).CopyToDataTable()
This could be tweaked to use other string functions depending on your requirements, for example the below checks if output_value
contains the string in the row rather than starts with it.
dt_datatable.AsEnumerable.Where(Function (r) output_value.Contains(r.Item("partial").ToString())).CopyToDataTable()
One of the difficult bits of development and it seems to crop up more in RPA is matching, you need to define exactly what you want to match on then create your rules around that. eg for a match it has to start with it not end with it, or it just must contain it etc...