Using v2.5.
I would like to use a regular expression to sort data returned from LLBLGen (either, returned datatable or projection).
In the past (before LLBLGen) I have had to return the recordset to a datatable. Manually add a column to the datatable in code and go through each row in a for/each and do the regular expression pattern match and append the matched values together into the new field. I would then take the dataset and pluck it into a dataview and sort on the added field. I was basically using the reg. exp. to do a pettern match and stripping characters out that didn't match that pattern and then sorting on the returned value.
This would be useful for those times where you need a specialized sort that cannot rely on either Ascending or Descending.
Here is an example of the code used to the the value to put in the new field and sort on:
Dim x As New System.Text.RegularExpressions.Regex("\d+\.?\d*|\.\d+")
'Diagnostics.Debug.WriteLine(x.Match(st).ToString)
'x = New System.Text.RegularExpressions.Regex("\b\d+\b")
'Diagnostics.Debug.WriteLine(x.Match(st).ToString)
'Append each match to form one number
Dim mc As Text.RegularExpressions.MatchCollection
mc = x.Matches(st)
Try
If mc.Count > 1 Then
Dim m As Text.RegularExpressions.Match
Dim stReturn As String
For Each m In mc
stReturn += m.ToString
Next
Return Val(stReturn)
Else
Return Val(x.Match(st).ToString)
End If
Catch ex As Exception
'catch any errors - relating to Val or integer data type (maybe number was too long)
'MsgBox(ex.ToString)
Return Integer.MaxValue
End Try